summaryrefslogtreecommitdiffstats
path: root/mso-catalog-db/src/main/java/org
diff options
context:
space:
mode:
authorxg353y <xg353y@intl.att.com>2017-04-11 13:30:42 +0200
committerxg353y <xg353y@intl.att.com>2017-04-11 15:34:19 +0200
commitb6b7bef8bdcad15af01ac88a038dd763ce59f68f (patch)
tree399d39da23aaa37701e487df064e3e0c27709ef3 /mso-catalog-db/src/main/java/org
parent19340cad94eeaa1b580f7c0c99531de499e8ca14 (diff)
[MSO-8] Update the maven dependency
Update the maven depenency for sdc-distribution-client to cooperate with the sdc changes. Change-Id: I2da936e5c40cb68c7181bb78307192dd5655b5dc Signed-off-by: xg353y <xg353y@intl.att.com>
Diffstat (limited to 'mso-catalog-db/src/main/java/org')
-rw-r--r--mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/CatalogDatabase.java1372
-rw-r--r--mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/HibernateUtilsCatalogDb.java45
-rw-r--r--mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/AllottedResourceCustomization.java123
-rw-r--r--mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatEnvironment.java18
-rw-r--r--mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatFiles.java29
-rw-r--r--mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatTemplate.java28
-rw-r--r--mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/Model.java198
-rw-r--r--mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ModelRecipe.java180
-rw-r--r--mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/NetworkResourceCustomization.java140
-rw-r--r--mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceMacroHolder.java141
-rw-r--r--mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceRecipe.java42
-rw-r--r--mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceToAllottedResources.java67
-rw-r--r--mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceToNetworks.java68
-rw-r--r--mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VfModule.java89
-rw-r--r--mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfResource.java82
-rw-r--r--mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/utils/MavenLikeVersioning.java9
-rw-r--r--mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/utils/RecordNotFoundException.java49
17 files changed, 2496 insertions, 184 deletions
diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/CatalogDatabase.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/CatalogDatabase.java
index 70b9618265..38e711eb16 100644
--- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/CatalogDatabase.java
+++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/CatalogDatabase.java
@@ -21,6 +21,7 @@
package org.openecomp.mso.db.catalog;
import java.io.Closeable;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@@ -35,7 +36,9 @@ import org.hibernate.cfg.Configuration;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.service.ServiceRegistryBuilder;
+import org.openecomp.mso.db.HibernateUtils;
import org.openecomp.mso.db.catalog.utils.MavenLikeVersioningComparator;
+import org.openecomp.mso.db.catalog.utils.RecordNotFoundException;
import org.openecomp.mso.logger.MessageEnum;
import org.openecomp.mso.logger.MsoLogger;
@@ -48,18 +51,21 @@ import org.openecomp.mso.logger.MsoLogger;
*/
public class CatalogDatabase implements Closeable {
- protected static final String NETWORK_TYPE = "networkType";
- protected static final String ACTION = "action";
- protected static final String VNF_TYPE = "vnfType";
- protected static final String SERVICE_TYPE = "serviceType";
- protected static final String VNF_COMPONENT_TYPE = "vnfComponentType";
- protected static final String MODEL_NAME = "modelName";
- protected static final String TYPE = "type";
- protected static final String VF_MODULE_ID = "vfModuleId";
- protected static boolean initialized = false;
- protected static SessionFactory sessionFactory;
- protected static ServiceRegistry serviceRegistry;
- protected static final String SERVICE_NAME_VERSION_ID= "serviceNameVersionId";
+ protected static HibernateUtils hibernateUtils = new HibernateUtilsCatalogDb ();
+
+ 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_ID = "modelId";
+ private static final String MODEL_NAME = "modelName";
+ private static final String TYPE = "type";
+ private static final String MODEL_TYPE = "modelType";
+ private static final String MODEL_VERSION_ID = "modelVersionId";
+ private static final String MODEL_CUSTOMIZATION_UUID = "modelCustomizationUuid";
+ private static final String VF_MODULE_ID = "vfModuleId";
+ private static final String SERVICE_NAME_VERSION_ID= "serviceNameVersionId";
protected static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.GENERAL);
@@ -70,33 +76,10 @@ public class CatalogDatabase implements Closeable {
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) {
+
+ if (session == null) {
try {
- session = sessionFactory.openSession ();
+ session = hibernateUtils.getSessionFactory ().openSession ();
session.beginTransaction ();
} catch (HibernateException he) {
LOGGER.error (MessageEnum.GENERAL_EXCEPTION_ARG, "Error creating Hibernate Session: " + he, "", "", MsoLogger.ErrorCode.DataError, "Error creating Hibernate Session: " + he);
@@ -231,6 +214,33 @@ public class CatalogDatabase implements Closeable {
}
/**
+ * Fetch a Service definition by InvariantUUID
+ */
+ public Service getServiceByInvariantUUID (String modelInvariantUUID) {
+
+ long startTime = System.currentTimeMillis ();
+ LOGGER.debug ("Catalog database - get service with Invariant UUID " + modelInvariantUUID);
+
+ String hql = "FROM Service WHERE modelInvariantUUID = :model_invariant_uuid";
+ Query query = getSession ().createQuery (hql);
+ query.setParameter ("model_invariant_uuid", modelInvariantUUID);
+
+ @SuppressWarnings("unchecked")
+ List <Service> resultList = query.list ();
+
+ // See if something came back.
+ if (resultList.isEmpty ()) {
+ LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. Service not found", "CatalogDB", "getServiceByName", null);
+ return null;
+ }
+ 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);
+ }
+
+ /**
* Fetch a Service definition
*/
public Service getService (String serviceName) {
@@ -388,6 +398,33 @@ public class CatalogDatabase implements Closeable {
return resultList.get (0);
}
+ public Service getServiceByVersionAndInvariantId(String modelInvariantId, String modelVersion) throws Exception {
+ long startTime = System.currentTimeMillis ();
+ LOGGER.debug ("Catalog database - get service with modelInvariantId: " + modelInvariantId + " and modelVersion: " + modelVersion);
+
+ String hql = "FROM Service WHERE modelInvariantUUID = :MODEL_INVARIANT_UUID AND version = :VERSION_STR";
+ Query query = getSession ().createQuery (hql);
+ query.setParameter ("MODEL_INVARIANT_UUID", modelInvariantId);
+ query.setParameter("VERSION_STR", modelVersion);
+
+ Service result = null;
+ try {
+ result = (Service) query.uniqueResult();
+ } catch (org.hibernate.NonUniqueResultException nure) {
+ LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique row - data integrity error: modelInvariantId='" + modelInvariantId + "', modelVersion='" + modelVersion + "'");
+ LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for modelInvariantId=" + modelInvariantId + " and modelVersion=" + modelVersion, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for modelInvariantId=" + modelInvariantId);
+ throw new Exception("Non Unique Result Exception - the Catalog Database does not match a unique row - data integrity error: modelInvariantId='" + modelInvariantId + "', modelVersion='" + modelVersion + "'");
+ }
+ // See if something came back.
+ if (result==null) {
+ LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. Service not found", "CatalogDB", "getServiceByVersionAndInvariantId", null);
+ return null;
+ }
+
+ LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getServiceByVersionAndInvariantId", null);
+ return result;
+ }
+
/**
* Return a Service recipe that matches a given SERVICE_NAME_VERSION_ID
* (MODEL_VERSION_ID) and ACTION
@@ -439,10 +476,15 @@ public class CatalogDatabase implements Closeable {
* @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 ");
-
-
+
+ StringBuilder hql = null;
+
+ if(action == null){
+ hql = new StringBuilder ("FROM ServiceRecipe WHERE serviceId = :serviceId");
+ }else {
+ 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 "
@@ -452,7 +494,10 @@ public class CatalogDatabase implements Closeable {
Query query = getSession ().createQuery (hql.toString ());
query.setParameter ("serviceId", serviceId);
query.setParameter (ACTION, action);
-
+ if(action != null){
+ query.setParameter (ACTION, action);
+ }
+
@SuppressWarnings("unchecked")
List <ServiceRecipe> resultList = query.list ();
@@ -468,7 +513,33 @@ public class CatalogDatabase implements Closeable {
return resultList.get (0);
}
-
+ public List<ServiceRecipe> getServiceRecipes (int serviceId) {
+
+ StringBuilder hql = null;
+
+ hql = new StringBuilder ("FROM ServiceRecipe WHERE serviceId = :serviceId");
+
+ long startTime = System.currentTimeMillis ();
+ LOGGER.debug ("Catalog database - get Service recipe with serviceId " + Integer.toString(serviceId));
+
+ Query query = getSession ().createQuery (hql.toString ());
+ query.setParameter ("serviceId", serviceId);
+
+ @SuppressWarnings("unchecked")
+ List <ServiceRecipe> resultList = query.list ();
+
+ if (resultList.isEmpty ()) {
+ LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. Service recipe not found", "CatalogDB", "getServiceRecipes", null);
+ return null;
+ }
+
+ Collections.sort (resultList, new MavenLikeVersioningComparator ());
+ Collections.reverse (resultList);
+
+ LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getServiceRecipes", null);
+ return resultList;
+ }
+
/**
* Return the VNF component data - queried by the VNFs ID and the component type.
*
@@ -477,10 +548,10 @@ public class CatalogDatabase implements Closeable {
* @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);
@@ -488,7 +559,7 @@ public class CatalogDatabase implements Closeable {
VnfComponent result = null;
try {
- result = (VnfComponent) query.uniqueResult();
+ 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);
@@ -584,6 +655,47 @@ public class CatalogDatabase implements Closeable {
}
/**
+ * Return the newest version of a specific VNF resource (queried by modelCustomizationId).
+ *
+ * @param vnfType
+ * @param version
+ * @return VnfResource object or null if none found
+ */
+ public VnfResource getVnfResourceByModelCustomizationId (String modelCustomizationId, String serviceVersion) {
+
+ long startTime = System.currentTimeMillis ();
+ LOGGER.debug ("Catalog database - get VNF resource with modelCustomizationId " + modelCustomizationId);
+
+ String hql = "FROM VnfResource WHERE modelCustomizationUuid = :modelCustomizationId and version = :serviceVersion";
+ Query query = getSession ().createQuery (hql);
+ query.setParameter ("modelCustomizationId", modelCustomizationId);
+ 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: modelCustomizationUuid='" + modelCustomizationId + "', serviceVersion='" + serviceVersion + "'");
+ LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for modelCustomizationUuid=" + modelCustomizationId + " and serviceVersion=" + serviceVersion, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for modelCustomizationId=" + modelCustomizationId);
+ resource = null;
+ } catch (org.hibernate.HibernateException he) {
+ LOGGER.debug("Hibernate Exception - while searching for: modelCustomizationId='" + modelCustomizationId + "', asdc_service_model_version='" + serviceVersion + "'");
+ LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching for modelCustomizationId=" + modelCustomizationId + " and serviceVersion=" + serviceVersion, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for modelCustomizationId=" + modelCustomizationId);
+ resource = null;
+ } catch (Exception e) {
+ LOGGER.debug("Generic Exception - while searching for: modelCustomizationId='" + modelCustomizationId + "', serviceVersion='" + serviceVersion + "'");
+ LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception searching for modelCustomizationId=" + modelCustomizationId + " and serviceVersion=" + serviceVersion, "", "", MsoLogger.ErrorCode.DataError, "Generic exception searching for modelCustomizationId=" + modelCustomizationId);
+ 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
@@ -791,7 +903,7 @@ public class CatalogDatabase implements Closeable {
* Return a VNF recipe that matches a given VF_MODULE_ID and ACTION
*
* @param vfModuleId
- * @param action
+ * @param action
* @return VnfRecipe object or null if none found
*/
public VnfRecipe getVnfRecipeByVfModuleId (String vnfType, String vfModuleId, String action) {
@@ -819,7 +931,39 @@ public class CatalogDatabase implements Closeable {
LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. VNF Recipe Entry found", "CatalogDB", "getVnfRecipeByVfModuleId", null);
return resultList.get (0);
}
-
+
+ public VfModule getVfModuleTypeByUuid(String modelCustomizationUuid) {
+ long startTime = System.currentTimeMillis();
+ LOGGER.debug("Catalog database - get vfModuleTypeByUuid with uuid=" + modelCustomizationUuid);
+
+ String hql = "FROM VfModule WHERE modelCustomizationUuid = :modelCustomizationUuid";
+ Query query = getSession().createQuery(hql);
+ query.setParameter("modelCustomizationUuid", modelCustomizationUuid);
+
+ VfModule module = null;
+ try {
+ module = (VfModule) query.uniqueResult();
+ } catch (org.hibernate.NonUniqueResultException nure) {
+ LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique row - data integrity error: modelCustomizationUuid='" + modelCustomizationUuid + "'");
+ LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for modelCustomizationUuid=" + modelCustomizationUuid, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for modelCustomizationUuid==" + modelCustomizationUuid);
+ module = null;
+ } catch (org.hibernate.HibernateException he) {
+ LOGGER.debug("Hibernate Exception - while searching for: modelCustomizationUuid='" + modelCustomizationUuid + "'");
+ LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching for modelCustomizationUuid=" + modelCustomizationUuid, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for modelCustomizationUuid=" + modelCustomizationUuid);
+ module = null;
+ } catch (Exception e) {
+ LOGGER.debug("Generic Exception - while searching for: modelCustomizationUuid='" + modelCustomizationUuid + "'");
+ LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception searching for modelCustomizationUuid=" + modelCustomizationUuid, "", "", MsoLogger.ErrorCode.DataError, "Generic exception searching for modelCustomizationUuid=" + modelCustomizationUuid);
+ module = null;
+ }
+ if (module == null) {
+ LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "NotFound", "CatalogDB", "getVfModuleTypeByUuid", null);
+ } else {
+ LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVfModuleTypeByUuid", null);
+ }
+ return module;
+ }
+
public VfModule getVfModuleType(String type) {
long startTime = System.currentTimeMillis();
LOGGER.debug("Catalog database - get vfModuleType with type " + type);
@@ -873,8 +1017,745 @@ public class CatalogDatabase implements Closeable {
}
return module;
}
-
-
+
+ public VnfResource getVnfResourceByServiceUuid(String serviceModelInvariantUuid) {
+ long startTime = System.currentTimeMillis();
+ LOGGER.debug ("Catalog database - get vfModuleType with serviceModelInvariantUuid " + serviceModelInvariantUuid);
+
+ String hql = "FROM VnfResource WHERE serviceModelInvariantUuid = :serviceModelInvariantUuid";
+ Query query = getSession().createQuery(hql);
+ query.setParameter ("serviceModelInvariantUuid", serviceModelInvariantUuid);
+ VnfResource vnfResource = null;
+ try {
+ vnfResource = (VnfResource) query.uniqueResult ();
+ } catch (org.hibernate.NonUniqueResultException nure) {
+ LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique row - data integrity error: serviceModelInvariantUuid='" + serviceModelInvariantUuid);
+ LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for serviceModelInvariantUuid=" + serviceModelInvariantUuid, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for serviceModelInvariantUuid==" + serviceModelInvariantUuid);
+ vnfResource = null;
+ } catch (org.hibernate.HibernateException he) {
+ LOGGER.debug("Hibernate Exception - while searching for: serviceModelInvariantUuid='" + serviceModelInvariantUuid + "'");
+ LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching for serviceModelInvariantUuid=" + serviceModelInvariantUuid, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for serviceModelInvariantUuid=" + serviceModelInvariantUuid);
+ vnfResource = null;
+ } catch (Exception e) {
+ LOGGER.debug("Generic Exception - while searching for: serviceModelInvariantUuid='" + serviceModelInvariantUuid + "'");
+ LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception searching for serviceModelInvariantUuid=" + serviceModelInvariantUuid, "", "", MsoLogger.ErrorCode.DataError, "Generic exception searching for serviceModelInvariantUuid=" + serviceModelInvariantUuid);
+ vnfResource = null;
+ }
+ if (vnfResource == null) {
+ LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "NotFound", "CatalogDB", "getVfModuleType", null);
+ } else {
+ LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVfModuleType", null);
+ }
+ return vnfResource;
+ }
+
+ public VnfResource getVnfResourceByVnfUuid(String vnfResourceModelInvariantUuid) {
+ long startTime = System.currentTimeMillis();
+ LOGGER.debug ("Catalog database - get vfModuleType with vnfResourceModelInvariantUuid " + vnfResourceModelInvariantUuid);
+
+ String hql = "FROM VnfResource WHERE vnfResourceModelInvariantUuid = :vnfResourceModelInvariantUuid";
+ Query query = getSession().createQuery(hql);
+ query.setParameter ("vnfResourceModelInvariantUuid", vnfResourceModelInvariantUuid);
+ VnfResource vnfResource = null;
+ try {
+ vnfResource = (VnfResource) query.uniqueResult ();
+ } catch (org.hibernate.NonUniqueResultException nure) {
+ LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique row - data integrity error: vnfResourceModelInvariantUuid='" + vnfResourceModelInvariantUuid);
+ LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for vnfResourceModelInvariantUuid=" + vnfResourceModelInvariantUuid, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for vnfResourceModelInvariantUuid==" + vnfResourceModelInvariantUuid);
+ vnfResource = null;
+ } catch (org.hibernate.HibernateException he) {
+ LOGGER.debug("Hibernate Exception - while searching for: vnfResourceModelInvariantUuid='" + vnfResourceModelInvariantUuid + "'");
+ LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching for vnfResourceModelInvariantUuid=" + vnfResourceModelInvariantUuid, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for vnfResourceModelInvariantUuid=" + vnfResourceModelInvariantUuid);
+ vnfResource = null;
+ } catch (Exception e) {
+ LOGGER.debug("Generic Exception - while searching for: vnfResourceModelInvariantUuid='" + vnfResourceModelInvariantUuid + "'");
+ LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception searching for vnfResourceModelInvariantUuid=" + vnfResourceModelInvariantUuid, "", "", MsoLogger.ErrorCode.DataError, "Generic exception searching for vnfResourceModelInvariantUuid=" + vnfResourceModelInvariantUuid);
+ vnfResource = null;
+ }
+ if (vnfResource == null) {
+ LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "NotFound", "CatalogDB", "getVfModuleType", null);
+ } else {
+ LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVfModuleType", null);
+ }
+ return vnfResource;
+ }
+
+ public VnfResource getVnfResourceByType(String vnfType) {
+ return this.getVnfResource(vnfType);
+ }
+
+ public VfModule getVfModuleByModelInvariantUuid(String vfModuleModelInvariantUuid) {
+ long startTime = System.currentTimeMillis();
+ LOGGER.debug ("Catalog database - get vfModuleTypeByUuid with uuid " + vfModuleModelInvariantUuid);
+
+ String hql = "FROM VfModule WHERE vfModuleModelInvariantUuid = :vfModuleModelInvariantUuid ";
+ Query query = getSession().createQuery(hql);
+ query.setParameter ("vfModuleModelInvariantUuid", vfModuleModelInvariantUuid);
+ 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: vfModuleModelInvariantUuid='" + vfModuleModelInvariantUuid + "'");
+ LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for vfModuleModelInvariantUuid=" + vfModuleModelInvariantUuid , "", "", MsoLogger.ErrorCode.DataError, "Non unique result for vfModuleModelInvariantUuid==" + vfModuleModelInvariantUuid);
+ module = null;
+ } catch (org.hibernate.HibernateException he) {
+ LOGGER.debug("Hibernate Exception - while searching for: vfModuleModelInvariantUuid='" + vfModuleModelInvariantUuid + "'");
+ LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching for vfModuleModelInvariantUuid=" + vfModuleModelInvariantUuid, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for vfModuleModelInvariantUuid=" + vfModuleModelInvariantUuid);
+ module = null;
+ } catch (Exception e) {
+ LOGGER.debug("Generic Exception - while searching for: vfModuleModelInvariantUuid='" + vfModuleModelInvariantUuid + "'");
+ LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception searching for vfModuleModelInvariantUuid=" + vfModuleModelInvariantUuid, "", "", MsoLogger.ErrorCode.DataError, "Generic exception searching for vfModuleModelInvariantUuid=" + vfModuleModelInvariantUuid);
+ module = null;
+ }
+ if (module == null) {
+ LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "NotFound", "CatalogDB", "getVfModuleByModelInvariantUuid", null);
+ } else {
+ LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVfModuleByModelInvariantUuid", null);
+ }
+ return module;
+ }
+
+ public VfModule getVfModuleByModelCustomizationUuid(String modelCustomizationUuid) {
+ long startTime = System.currentTimeMillis();
+ LOGGER.debug ("Catalog database - get vfModuleTypeByModelCustomizationUuid with uuid " + modelCustomizationUuid);
+
+ String hql = "FROM VfModule WHERE modelCustomizationUuid = :modelCustomizationUuid ";
+ Query query = getSession().createQuery(hql);
+ query.setParameter ("modelCustomizationUuid", modelCustomizationUuid);
+ VfModule module = null;
+ try {
+ module = (VfModule) query.uniqueResult ();
+ } catch (org.hibernate.NonUniqueResultException nure) {
+ LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique row - data integrity error: modelCustomizationUuid='" + modelCustomizationUuid + "'");
+ LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for vfModuleModelInvariantUuid=" + modelCustomizationUuid , "", "", MsoLogger.ErrorCode.DataError, "Non unique result for modelCustomizationUuid==" + modelCustomizationUuid);
+ module = null;
+ } catch (org.hibernate.HibernateException he) {
+ LOGGER.debug("Hibernate Exception - while searching for: modelCustomizationUuid='" + modelCustomizationUuid + "'");
+ LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching for modelCustomizationUuid=" + modelCustomizationUuid, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for modelCustomizationUuid=" + modelCustomizationUuid);
+ module = null;
+ } catch (Exception e) {
+ LOGGER.debug("Generic Exception - while searching for: modelCustomizationUuid='" + modelCustomizationUuid + "'");
+ LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception searching for modelCustomizationUuid=" + modelCustomizationUuid, "", "", MsoLogger.ErrorCode.DataError, "Generic exception searching for modelCustomizationUuid=" + modelCustomizationUuid);
+ module = null;
+ }
+ if (module == null) {
+ LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "NotFound", "CatalogDB", "getVfModuleByModelCustomizationUuid", null);
+ } else {
+ LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVfModuleByModelCustomizationUuid", null);
+ }
+ return module;
+ }
+
+ public VfModule getVfModuleByType(String vfModuleType) {
+ return this.getVfModuleType(vfModuleType);
+ }
+
+ public List<VfModule> getVfModulesForVnfResource(VnfResource vnfResource) {
+ if (vnfResource == null)
+ return null;
+ int vnfResourceId = vnfResource.getId();
+
+ long startTime = System.currentTimeMillis();
+ LOGGER.debug("Catalog database - getVfModulesForVnfResource - vnfResource: " + vnfResource.toString());
+
+ return this.getVfModulesForVnfResource(vnfResourceId);
+
+ }
+
+ public List<VfModule> getVfModulesForVnfResource(int vnfResourceId) {
+ long startTime = System.currentTimeMillis();
+ LOGGER.debug("Catalog database - getVfModulesForVnfResource - vnfResourceId: " + vnfResourceId);
+ StringBuilder hql = new StringBuilder("FROM VfModule where vnfResourceId = :vnfResourceId");
+ Query query = getSession().createQuery(hql.toString());
+ query.setParameter("vnfResourceId", vnfResourceId);
+ List<VfModule> resultList = null;
+ try {
+ resultList = query.list();
+ if (resultList != null)
+ LOGGER.debug("\tQuery found " + resultList.size() + " records.");
+ else
+ LOGGER.debug("\tQuery found no records.");
+ } catch (org.hibernate.HibernateException he) {
+ LOGGER.debug("Hibernate Exception - getVfModulesForVnfResource - while searching for: vnfResourceId='" + vnfResourceId + " " + he.getMessage());
+ LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception - getVfModulesForVnfResource - searching for vnfResourceId=" + vnfResourceId, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for vnfResourceId=" + vnfResourceId);
+ } catch (Exception e) {
+ LOGGER.debug("Exception - getVfModulesForVnfResource - while searching for: vnfResourceId='" + vnfResourceId + " " + e.getMessage());
+ LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception - getVfModulesForVnfResource - searching for vnfResourceId=" + vnfResourceId, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for vnfResourceId=" + vnfResourceId);
+ }
+ if (resultList == null) {
+ resultList = new ArrayList<VfModule>();
+ }
+ LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVfModulesForVnfResource", null);
+ return resultList;
+ }
+
+ public Service getServiceByUuid (String serviceModelInvariantUuid) {
+
+ long startTime = System.currentTimeMillis ();
+ LOGGER.debug ("Catalog database - get service with ModelInvariantUuid " + serviceModelInvariantUuid);
+
+ String hql = "FROM Service WHERE modelInvariantUUID = :serviceModelInvariantUuid";
+ Query query = getSession ().createQuery (hql);
+ query.setParameter ("serviceModelInvariantUuid", serviceModelInvariantUuid);
+
+ Service service = null;
+ try {
+ service = (Service) query.uniqueResult ();
+ } catch (org.hibernate.NonUniqueResultException nure) {
+ LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique row - data integrity error: serviceModelInvariantUuid='" + serviceModelInvariantUuid + "'");
+ LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for serviceModelInvariantUuid=" + serviceModelInvariantUuid, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for serviceModelInvariantUuid=" + serviceModelInvariantUuid);
+ return null;
+ } catch (org.hibernate.HibernateException he) {
+ LOGGER.debug("Hibernate Exception - while searching for: serviceName='" + serviceModelInvariantUuid + "'");
+ LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching for serviceModelInvariantUuid=" + serviceModelInvariantUuid, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for serviceModelInvariantUuid=" + serviceModelInvariantUuid);
+ return null;
+ } catch (Exception e) {
+ LOGGER.debug("Generic Exception - while searching for: serviceModelInvariantUuid='" + serviceModelInvariantUuid);
+ LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception searching for serviceModelInvariantUuid=" + serviceModelInvariantUuid, "", "", MsoLogger.ErrorCode.DataError, "Generic exception searching for serviceModelInvariantUuid=" + serviceModelInvariantUuid);
+ 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;
+ }
+
+ public NetworkResource getNetworkResourceById(Integer id) {
+ long startTime = System.currentTimeMillis ();
+ LOGGER.debug ("Catalog database - getNetworkResource with id " + id);
+
+ String hql = "FROM NetworkResource WHERE id = :id";
+ Query query = getSession ().createQuery (hql);
+ query.setParameter ("id", id);
+
+ NetworkResource networkResource = null;
+ try {
+ networkResource = (NetworkResource) query.uniqueResult ();
+ } catch (org.hibernate.NonUniqueResultException nure) {
+ LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique row - data integrity error: NETWORK_RESOURCE.id='" + id + "'");
+ LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for NETWORK_RESOURCE.id=" + id, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for NETWORK_RESOURCE.id=" + id);
+ return null;
+ } catch (org.hibernate.HibernateException he) {
+ LOGGER.debug("Hibernate Exception - while searching for: NETWORK_RESOURCE.id='" + id + "'");
+ LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching for NETWORK_RESOURCE.id=" + id, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for NETWORK_RESOURCE.id=" + id);
+ return null;
+ } catch (Exception e) {
+ LOGGER.debug("Generic Exception - while searching for: NETWORK_RESOURCE.id='" + id);
+ LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception searching for NETWORK_RESOURCE.id=" + id, "", "", MsoLogger.ErrorCode.DataError, "Generic exception searching for NETWORK_RESOURCE.id=" + id);
+ return null;
+ }
+
+ LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getNetworkResourceById", null);
+ return networkResource;
+
+ }
+
+ // 1702 API Spec - Query for all networks in a Service:
+ public List<NetworkResourceCustomization> getAllNetworksByServiceModelUuid(String serviceModelUuid) {
+ long startTime = System.currentTimeMillis();
+ LOGGER.debug("Catalog database: getServiceNetworksByServiceModelUuid - " + serviceModelUuid);
+
+ // This is a 2-step process (3 really) - 1) query ServiceToNetworks, 2) query NetworkResourceCustomization, 3) populate the networkType
+
+ StringBuilder hql1 = new StringBuilder("FROM ServiceToNetworks WHERE serviceModelUuid = :serviceModelUuid");
+ Query query = getSession().createQuery(hql1.toString());
+ query.setParameter("serviceModelUuid", serviceModelUuid);
+ @SuppressWarnings("unchecked")
+ List<ServiceToNetworks> resultList1 = query.list();
+ if (resultList1 == null || resultList1.size() < 1) {
+ LOGGER.debug("Found no matches to the query - FROM ServiceToNetworks WHERE serviceModelUuid = " + serviceModelUuid);
+ return null;
+ }
+ LOGGER.debug("Found " + resultList1.size() + " entries in ServiceToNetworks with smu=" + serviceModelUuid);
+
+ ArrayList<NetworkResourceCustomization> masterList = new ArrayList<NetworkResourceCustomization>();
+ for (ServiceToNetworks stn : resultList1) {
+ String networkModelCustomizationUuid = stn.getNetworkModelCustomizationUuid();
+ LOGGER.debug("Now searching for NetworkResourceCustomization for " + networkModelCustomizationUuid);
+ List<NetworkResourceCustomization> resultSet = this.getAllNetworksByNetworkModelCustomizationUuid(networkModelCustomizationUuid);
+ for (NetworkResourceCustomization nrc : resultSet) {
+ masterList.add(nrc);
+ }
+ }
+ LOGGER.debug("Returning " + masterList.size() + " NRC records");
+ LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getAllNetworksByServiceModelUuid", null);
+ return masterList;
+
+ }
+ public List<NetworkResourceCustomization> getAllNetworksByServiceModelInvariantUuid(String serviceModelInvariantUuid) {
+ long startTime = System.currentTimeMillis();
+ LOGGER.debug("Catalog database: getServiceNetworksByServiceModelInvariantUuid - " + serviceModelInvariantUuid);
+
+ StringBuilder hql = new StringBuilder("FROM Service WHERE modelInvariantUUID = :serviceModelInvariantUuid");
+ Query query = getSession().createQuery(hql.toString());
+ query.setParameter("serviceModelInvariantUuid", serviceModelInvariantUuid);
+ @SuppressWarnings("unchecked")
+ List<Service> serviceList = query.list();
+
+ if (serviceList.isEmpty()) {
+ LOGGER.debug("Could not find Service for " + serviceModelInvariantUuid);
+ return null;
+ }
+
+ Collections.sort (serviceList, new MavenLikeVersioningComparator ());
+ Collections.reverse (serviceList);
+ Service service = serviceList.get(0);
+
+ String serviceNameVersionId = service.getServiceNameVersionId();
+ LOGGER.debug("The highest version for the Service " + serviceModelInvariantUuid + " is " + serviceNameVersionId);
+
+ // Service.serviceNameVersionId == ServiceToNetworks.serviceModelUuid
+ return this.getAllNetworksByServiceModelUuid(serviceNameVersionId);
+ }
+ public List<NetworkResourceCustomization> getAllNetworksByServiceModelInvariantUuid(String serviceModelInvariantUuid, String serviceModelVersion) {
+ long startTime = System.currentTimeMillis();
+ LOGGER.debug("Catalog database: getServiceNetworksByServiceModelInvariantUuid - " + serviceModelInvariantUuid + ", version=" + serviceModelVersion);
+
+ StringBuilder hql = new StringBuilder("FROM Service WHERE modelInvariantUUID = :serviceModelInvariantUuid and version = :serviceModelVersion");
+ Query query = getSession().createQuery(hql.toString());
+ query.setParameter("serviceModelInvariantUuid", serviceModelInvariantUuid);
+ query.setParameter("serviceModelVersion", serviceModelVersion);
+
+ //TODO
+ //can fix this later - no time - could do a unique query here - but this should work
+ @SuppressWarnings("unchecked")
+ List<Service> serviceList = query.list();
+
+ if (serviceList.isEmpty()) {
+ LOGGER.debug("No Service found with smu=" + serviceModelInvariantUuid + " and smv=" + serviceModelVersion);
+ return null;
+ }
+
+ Collections.sort (serviceList, new MavenLikeVersioningComparator ());
+ Collections.reverse (serviceList);
+ Service service = serviceList.get(0);
+
+ String serviceNameVersionId = service.getServiceNameVersionId();
+
+ // Service.serviceNameVersionId == ServiceToNetworks.serviceModelUuid
+ return this.getAllNetworksByServiceModelUuid(serviceNameVersionId);
+
+ }
+ public List<NetworkResourceCustomization> getAllNetworksByNetworkModelCustomizationUuid(String networkModelCustomizationUuid) {
+ long startTime = System.currentTimeMillis();
+ LOGGER.debug("Catalog database: getAllNetworksByNetworkModelCustomizationUuid - " + networkModelCustomizationUuid);
+
+ StringBuilder hql = new StringBuilder("FROM NetworkResourceCustomization WHERE modelCustomizationUuid = :networkModelCustomizationUuid");
+ Query query = getSession().createQuery(hql.toString());
+ query.setParameter("networkModelCustomizationUuid", networkModelCustomizationUuid);
+
+ @SuppressWarnings("unchecked")
+ List<NetworkResourceCustomization> resultList = query.list();
+
+ this.populateNetworkResourceType(resultList);
+
+ LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getAllNetworksByNetworkModelCustomizationUuid", null);
+ return resultList;
+ }
+ public List<NetworkResourceCustomization> getAllNetworksByNetworkType(String networkType) {
+ long startTime = System.currentTimeMillis();
+ LOGGER.debug("Catalog database: getServiceNetworksByNetworkType - " + networkType);
+
+ NetworkResource nr = this.getNetworkResource(networkType);
+ if (nr == null) {
+ return new ArrayList<NetworkResourceCustomization>();
+ }
+ Integer networkResourceId = nr.getId();
+
+ LOGGER.debug("Now searching for NRC's with networkResourceId = " + networkResourceId);
+ StringBuilder hql = new StringBuilder("FROM NetworkResourceCustomization WHERE networkResourceId = :networkResourceId");
+
+ Query query = getSession().createQuery(hql.toString());
+ query.setParameter("networkResourceId", networkResourceId);
+
+ @SuppressWarnings("unchecked")
+ List<NetworkResourceCustomization> resultList = query.list();
+
+ if (resultList != null && resultList.size() > 0) {
+ LOGGER.debug("Found " + resultList.size() + " results");
+ for (NetworkResourceCustomization nrc : resultList) {
+ nrc.setNetworkType(networkType);
+ nrc.setNetworkResource(nr);
+ }
+ }
+ LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getAllNetworksByNetworkType", null);
+
+ return resultList;
+ }
+
+ //1702 API Spec cont'd - Query for all VnfResources in a Service:
+ public List<VnfResource> getAllVnfsByServiceModelUuid(String serviceModelUuid) {
+ long startTime = System.currentTimeMillis();
+ LOGGER.debug("Catalog database: getAllVnfsByServiceModelUuid - " + serviceModelUuid);
+
+ StringBuilder hql = new StringBuilder("FROM Service WHERE serviceNameVersionId = :serviceModelUuid");
+ Query query = getSession().createQuery(hql.toString());
+ query.setParameter("serviceModelUuid", serviceModelUuid);
+ @SuppressWarnings("unchecked")
+ List<Service> serviceList = query.list();
+
+ if (serviceList.isEmpty()) {
+ return null;
+ }
+
+ Collections.sort (serviceList, new MavenLikeVersioningComparator ());
+ Collections.reverse (serviceList);
+ Service service = serviceList.get(0);
+
+ String serviceModelInvariantUuid = service.getModelInvariantUUID();
+ String serviceModelVersion = service.getVersion();
+
+ return this.getAllVnfsByServiceModelInvariantUuid(serviceModelInvariantUuid, serviceModelVersion);
+
+ }
+ public List<VnfResource> getAllVnfsByServiceModelInvariantUuid(String serviceModelInvariantUuid) {
+ long startTime = System.currentTimeMillis();
+ LOGGER.debug("Catalog database: getAllVnfsByServiceModelInvariantUuid - " + serviceModelInvariantUuid);
+
+ StringBuilder hqlService = new StringBuilder("FROM Service WHERE modelInvariantUUID = :serviceModelInvariantUuid");
+ Query query = getSession().createQuery(hqlService.toString());
+ query.setParameter("serviceModelInvariantUuid", serviceModelInvariantUuid);
+ @SuppressWarnings("unchecked")
+ List<Service> resultList = query.list();
+
+ if (resultList.isEmpty()) {
+ return null;
+ }
+ Collections.sort (resultList, new MavenLikeVersioningComparator ());
+ Collections.reverse (resultList);
+ Service service = resultList.get(0);
+ //now just call the method that takes the version - the service object will have the highest version
+ return this.getAllVnfsByServiceModelInvariantUuid(serviceModelInvariantUuid, service.getVersion());
+ }
+ public List<VnfResource> getAllVnfsByServiceModelInvariantUuid(String serviceModelInvariantUuid, String serviceModelVersion) {
+ long startTime = System.currentTimeMillis();
+ LOGGER.debug("Catalog database: getAllVnfsByServiceModelInvariantUuid - " + serviceModelInvariantUuid + ", version=" + serviceModelVersion);
+
+ StringBuilder hql = new StringBuilder("FROM VnfResource WHERE serviceModelInvariantUUID = :serviceModelInvariantUuid and version = :serviceModelVersion");
+ Query query = getSession().createQuery(hql.toString());
+ query.setParameter("serviceModelInvariantUuid", serviceModelInvariantUuid);
+ query.setParameter("serviceModelVersion", serviceModelVersion);
+
+ @SuppressWarnings("unchecked")
+ List<VnfResource> resultList = query.list();
+
+ if (resultList.isEmpty()) {
+ return null;
+ }
+ // so we have a list of VnfResource objects - but we need to add each one's VfModule objects
+ for (VnfResource vnfResource : resultList) {
+ List<VfModule> vfModules = this.getVfModulesForVnfResource(vnfResource);
+ if (vfModules != null && !vfModules.isEmpty()) {
+ for (VfModule vfm : vfModules) {
+ vnfResource.addVfModule(vfm);
+ }
+ }
+ }
+ LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getAllVnfsByServiceModelInvariantUuid", null);
+ return resultList;
+
+ }
+ public List<VnfResource> getAllVnfsByServiceName(String serviceName, String serviceVersion) {
+ long startTime = System.currentTimeMillis();
+ LOGGER.debug("Catalog database: getAllVnfsByServiceName - " + serviceName + ", version=" + serviceVersion);
+ if (serviceVersion == null || serviceVersion.equals("")) {
+ return this.getAllVnfsByServiceName(serviceName);
+ }
+
+ StringBuilder hql = new StringBuilder("FROM Service WHERE serviceName = :serviceName and version = :serviceVersion");
+ Query query = getSession().createQuery(hql.toString());
+ query.setParameter("serviceName", serviceName);
+ query.setParameter("serviceVersion", serviceVersion);
+
+ @SuppressWarnings("unchecked")
+ List<Service> resultList = query.list();
+
+ if (resultList.isEmpty()) {
+ return null;
+ }
+
+ Service service = resultList.get(0);
+
+ return this.getAllVnfsByServiceModelInvariantUuid(service.getModelInvariantUUID(), service.getVersion());
+ }
+ public List<VnfResource> getAllVnfsByServiceName(String serviceName) {
+ long startTime = System.currentTimeMillis();
+ LOGGER.debug("Catalog database: getAllVnfsByServiceName - " + serviceName);
+
+ StringBuilder hql = new StringBuilder("FROM Service WHERE serviceName = :serviceName");
+ Query query = getSession().createQuery(hql.toString());
+ query.setParameter("serviceName", serviceName);
+
+ @SuppressWarnings("unchecked")
+ List<Service> resultList = query.list();
+
+ if (resultList.isEmpty()) {
+ return null;
+ }
+ Collections.sort (resultList, new MavenLikeVersioningComparator ());
+ Collections.reverse (resultList);
+ Service service = resultList.get(0);
+
+ return this.getAllVnfsByServiceModelInvariantUuid(service.getModelInvariantUUID(), service.getVersion());
+ }
+ public List<VnfResource> getAllVnfsByVnfModelCustomizationUuid(String vnfModelCustomizationUuid) {
+ long startTime = System.currentTimeMillis();
+ LOGGER.debug("Catalog database: getAllVnfsByVnfModelCustomizationUuid - " + vnfModelCustomizationUuid);
+
+ StringBuilder hql = new StringBuilder("FROM VnfResource WHERE modelCustomizationUuid = :vnfModelCustomizationUuid");
+ Query query = getSession().createQuery(hql.toString());
+ query.setParameter("vnfModelCustomizationUuid", vnfModelCustomizationUuid);
+
+ @SuppressWarnings("unchecked")
+ List<VnfResource> resultList = query.list();
+
+ if (resultList.isEmpty()) {
+ LOGGER.debug("Found no records matching " + vnfModelCustomizationUuid);
+ return null;
+ }
+ // so we have a list of VnfResource objects - but we need to add each one's VfModule objects
+ for (VnfResource vnfResource : resultList) {
+ LOGGER.debug("Finding vfModules for vnfResource.id=" + vnfResource.getId());
+ List<VfModule> vfModules = this.getVfModulesForVnfResource(vnfResource);
+ if (vfModules != null && !vfModules.isEmpty()) {
+ LOGGER.debug("\tFound " + vfModules.size() + " vf modules");
+ for (VfModule vfm : vfModules) {
+ vnfResource.addVfModule(vfm);
+ }
+ }
+ }
+ LOGGER.debug("Returning " + resultList + " vnf modules");
+ LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getAllVnfsByVnfModelCustomizationUuid", null);
+ return resultList;
+ }
+
+ //1702 API Spec cont'd - Query for all allotted resources in a Service
+
+ public List<AllottedResourceCustomization> getAllAllottedResourcesByServiceModelUuid(String serviceModelUuid) {
+ long startTime = System.currentTimeMillis();
+ LOGGER.debug("Catalog database: getAllAllottedResourcesByServiceModelUuid - " + serviceModelUuid);
+
+ // This is a 2-step process (3 really) - 1) query ServiceToAllottedResources, 2) query AllottedResourceCustomization
+
+ StringBuilder hql1 = new StringBuilder("FROM ServiceToAllottedResources WHERE serviceModelUuid = :serviceModelUuid");
+ Query query = getSession().createQuery(hql1.toString());
+ query.setParameter("serviceModelUuid", serviceModelUuid);
+ @SuppressWarnings("unchecked")
+ List<ServiceToAllottedResources> resultList1 = query.list();
+ if (resultList1 == null || resultList1.size() < 1) {
+ LOGGER.debug("Found no matches to the query " + hql1.toString());
+ return null;
+ }
+ LOGGER.debug("Found " + resultList1.size() + " entries in ServiceToAllottedResources with smu=" + serviceModelUuid);
+
+ ArrayList<AllottedResourceCustomization> masterList = new ArrayList<AllottedResourceCustomization>();
+ for (ServiceToAllottedResources star : resultList1) {
+ String arModelCustomizationUuid = star.getArModelCustomizationUuid();
+ LOGGER.debug("Now searching for AllottedResourceCustomization for " + arModelCustomizationUuid);
+ List<AllottedResourceCustomization> resultSet = this.getAllAllottedResourcesByArModelCustomizationUuid(arModelCustomizationUuid);
+ for (AllottedResourceCustomization arc : resultSet) {
+ masterList.add(arc);
+ }
+ }
+ LOGGER.debug("Returning " + masterList.size() + " ARC records");
+ LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getAllAllottedResourcesByServiceModelUuid", null);
+ return masterList;
+ }
+
+ public List<AllottedResourceCustomization> getAllAllottedResourcesByServiceModelInvariantUuid(String serviceModelInvariantUuid) {
+ long startTime = System.currentTimeMillis();
+ LOGGER.debug("Catalog database: getAllAllottedResourcesByServiceModelInvariantUuid - " + serviceModelInvariantUuid);
+
+ StringBuilder hql = new StringBuilder("FROM Service WHERE modelInvariantUUID = :serviceModelInvariantUuid");
+ Query query = getSession().createQuery(hql.toString());
+ query.setParameter("serviceModelInvariantUuid", serviceModelInvariantUuid);
+ @SuppressWarnings("unchecked")
+ List<Service> serviceList = query.list();
+
+ if (serviceList.isEmpty()) {
+ LOGGER.debug("Could not find Service for " + serviceModelInvariantUuid);
+ return null;
+ }
+
+ Collections.sort (serviceList, new MavenLikeVersioningComparator ());
+ Collections.reverse (serviceList);
+ Service service = serviceList.get(0);
+
+ String serviceNameVersionId = service.getServiceNameVersionId();
+ LOGGER.debug("The highest version for the Service " + serviceModelInvariantUuid + " is " + serviceNameVersionId);
+
+ // Service.serviceNameVersionId == ServiceToAllottedResources.serviceModelUuid
+ return this.getAllAllottedResourcesByServiceModelUuid(serviceNameVersionId);
+ }
+
+ public List<AllottedResourceCustomization> getAllAllottedResourcesByServiceModelInvariantUuid(String serviceModelInvariantUuid, String serviceModelVersion) {
+ long startTime = System.currentTimeMillis();
+ LOGGER.debug("Catalog database: getAllAllottedResourcesByServiceModelInvariantUuid - " + serviceModelInvariantUuid + ", version=" + serviceModelVersion);
+
+ StringBuilder hql = new StringBuilder("FROM Service WHERE modelInvariantUUID = :serviceModelInvariantUuid and version = :serviceModelVersion");
+ Query query = getSession().createQuery(hql.toString());
+ query.setParameter("serviceModelInvariantUuid", serviceModelInvariantUuid);
+ query.setParameter("serviceModelVersion", serviceModelVersion);
+
+ //TODO
+ //can fix this later - no time - could do a unique query here - but this should work
+ @SuppressWarnings("unchecked")
+ List<Service> serviceList = query.list();
+
+ if (serviceList.isEmpty()) {
+ LOGGER.debug("No Service found with smu=" + serviceModelInvariantUuid + " and smv=" + serviceModelVersion);
+ return null;
+ }
+
+ Collections.sort (serviceList, new MavenLikeVersioningComparator ());
+ Collections.reverse (serviceList);
+ Service service = serviceList.get(0);
+
+ String serviceNameVersionId = service.getServiceNameVersionId();
+
+ // Service.serviceNameVersionId == ServiceToNetworks.serviceModelUuid
+ return this.getAllAllottedResourcesByServiceModelUuid(serviceNameVersionId);
+ }
+
+ public List<AllottedResourceCustomization> getAllAllottedResourcesByArModelCustomizationUuid(String arModelCustomizationUuid) {
+ long startTime = System.currentTimeMillis();
+ LOGGER.debug("Catalog database: getAllAllottedResourcesByArModelCustomizationUuid - " + arModelCustomizationUuid);
+
+ StringBuilder hql = new StringBuilder("FROM AllottedResourceCustomization WHERE modelCustomizationUuid = :arModelCustomizationUuid");
+ Query query = getSession().createQuery(hql.toString());
+ query.setParameter("arModelCustomizationUuid", arModelCustomizationUuid);
+
+ @SuppressWarnings("unchecked")
+ List<AllottedResourceCustomization> resultList = query.list();
+
+ LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getAllAllottedResourcesByArModelCustomizationUuid", null);
+ return resultList;
+ }
+
+ //1702 API Spec cont'd - Query for all resources in a Service:
+ public ServiceMacroHolder getAllResourcesByServiceModelUuid(String serviceModelUuid) {
+ long startTime = System.currentTimeMillis();
+ LOGGER.debug("Catalog database: getAllResourcesByServiceModelUuid - " + serviceModelUuid);
+
+ StringBuilder hql = new StringBuilder("FROM Service WHERE serviceNameVersionId = :serviceModelUuid");
+ Query query = getSession().createQuery(hql.toString());
+ query.setParameter("serviceModelUuid", serviceModelUuid);
+ @SuppressWarnings("unchecked")
+ List<Service> serviceList = query.list();
+
+ if (serviceList.isEmpty()) {
+ LOGGER.debug("Unable to find a Service with serviceModelUuid=" + serviceModelUuid);
+ return null;
+ }
+
+ Collections.sort (serviceList, new MavenLikeVersioningComparator ());
+ Collections.reverse (serviceList);
+ Service service = serviceList.get(0);
+
+ ServiceMacroHolder smh = new ServiceMacroHolder(service);
+ ArrayList<NetworkResourceCustomization> nrcList = (ArrayList<NetworkResourceCustomization>) this.getAllNetworksByServiceModelUuid(serviceModelUuid);
+ smh.setNetworkResourceCustomization(nrcList);
+ ArrayList<AllottedResourceCustomization> arcList = (ArrayList<AllottedResourceCustomization>) this.getAllAllottedResourcesByServiceModelUuid(serviceModelUuid);
+ smh.setAllottedResourceCustomization(arcList);
+ ArrayList<VnfResource> vnfList = (ArrayList<VnfResource>) this.getAllVnfsByServiceModelInvariantUuid(service.getModelInvariantUUID(), service.getVersion());
+ smh.setVnfResources(vnfList);
+
+ LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getAllResourcesByServiceModelUuid", null);
+ return smh;
+ }
+ public ServiceMacroHolder getAllResourcesByServiceModelInvariantUuid(String serviceModelInvariantUuid) {
+ long startTime = System.currentTimeMillis();
+ LOGGER.debug("Catalog database: getAllResourcesByServiceModelInvariantUuid - " + serviceModelInvariantUuid);
+
+ StringBuilder hql = new StringBuilder("FROM Service WHERE modelInvariantUUID = :serviceModelInvariantUuid");
+ Query query = getSession().createQuery(hql.toString());
+ query.setParameter("serviceModelInvariantUuid", serviceModelInvariantUuid);
+ @SuppressWarnings("unchecked")
+ List<Service> serviceList = query.list();
+
+ if (serviceList.isEmpty()) {
+ LOGGER.debug("Unable to find a Service with serviceModelInvariantUuid=" + serviceModelInvariantUuid);
+ return null;
+ }
+
+ Collections.sort (serviceList, new MavenLikeVersioningComparator ());
+ Collections.reverse (serviceList);
+ Service service = serviceList.get(0);
+
+ ServiceMacroHolder smh = new ServiceMacroHolder(service);
+ ArrayList<NetworkResourceCustomization> nrcList = (ArrayList<NetworkResourceCustomization>) this.getAllNetworksByServiceModelUuid(service.getServiceNameVersionId());
+ smh.setNetworkResourceCustomization(nrcList);
+ ArrayList<AllottedResourceCustomization> arcList = (ArrayList<AllottedResourceCustomization>) this.getAllAllottedResourcesByServiceModelUuid(service.getServiceNameVersionId());
+ smh.setAllottedResourceCustomization(arcList);
+ ArrayList<VnfResource> vnfList = (ArrayList<VnfResource>) this.getAllVnfsByServiceModelInvariantUuid(service.getModelInvariantUUID(), service.getVersion());
+ smh.setVnfResources(vnfList);
+
+ LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getAllResourcesByServiceModelInvariantUuid", null);
+ return smh;
+
+ }
+ public ServiceMacroHolder getAllResourcesByServiceModelInvariantUuid(String serviceModelInvariantUuid, String serviceModelVersion) {
+ long startTime = System.currentTimeMillis();
+ LOGGER.debug("Catalog database: getAllResourcesByServiceModelInvariantUuid - " + serviceModelInvariantUuid + ", version=" + serviceModelVersion);
+
+ StringBuilder hql = new StringBuilder("FROM Service WHERE modelInvariantUUID = :serviceModelInvariantUuid and version = :serviceModelVersion");
+ Query query = getSession().createQuery(hql.toString());
+ query.setParameter("serviceModelInvariantUuid", serviceModelInvariantUuid);
+ query.setParameter("serviceModelVersion", serviceModelVersion);
+ //TODO make this a unique query
+ @SuppressWarnings("unchecked")
+ List<Service> serviceList = query.list();
+
+ if (serviceList.isEmpty()) {
+ LOGGER.debug("Unable to find a Service with serviceModelInvariantUuid=" + serviceModelInvariantUuid + " and serviceModelVersion=" + serviceModelVersion);
+ return null;
+ }
+
+ Collections.sort (serviceList, new MavenLikeVersioningComparator ());
+ Collections.reverse (serviceList);
+ Service service = serviceList.get(0);
+
+ ServiceMacroHolder smh = new ServiceMacroHolder(service);
+ ArrayList<NetworkResourceCustomization> nrcList = (ArrayList<NetworkResourceCustomization>) this.getAllNetworksByServiceModelUuid(service.getServiceNameVersionId());
+ smh.setNetworkResourceCustomization(nrcList);
+ ArrayList<AllottedResourceCustomization> arcList = (ArrayList<AllottedResourceCustomization>) this.getAllAllottedResourcesByServiceModelUuid(service.getServiceNameVersionId());
+ smh.setAllottedResourceCustomization(arcList);
+ ArrayList<VnfResource> vnfList = (ArrayList<VnfResource>) this.getAllVnfsByServiceModelInvariantUuid(service.getModelInvariantUUID(), service.getVersion());
+ smh.setVnfResources(vnfList);
+
+ LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getAllResourcesByServiceModelUuid with version", null);
+ return smh;
+ }
+
+ private void populateNetworkResourceType(List<NetworkResourceCustomization> resultList) {
+ HashMap<Integer, NetworkResource> networkResources = new HashMap<Integer, NetworkResource>();
+
+ for (NetworkResourceCustomization nrc : resultList) {
+ Integer network_id = nrc.getNetworkResourceId();
+ if (network_id == null) {
+ nrc.setNetworkResource(null);
+ nrc.setNetworkType("UNKNOWN_NETWORK_ID_NULL");
+ continue;
+ }
+ if (networkResources.containsKey(network_id)) {
+ nrc.setNetworkResource(networkResources.get(network_id));
+ nrc.setNetworkType(networkResources.get(network_id).getNetworkType());
+ } else {
+ NetworkResource nr = this.getNetworkResourceById(network_id);
+ if (nr == null) {
+ nrc.setNetworkType("INVALID_NETWORK_TYPE_ID_NOT_FOUND");
+ } else {
+ nrc.setNetworkType(nr.getNetworkType());
+ nrc.setNetworkResource(nr);
+ networkResources.put(network_id, nr);
+ }
+ }
+ }
+ }
+
/**
* Return a VNF recipe that matches a given VNF_TYPE, VF_MODULE_MODEL_NAME, and ACTION
* first query VF_MODULE table by type, and then use the ID to query
@@ -936,33 +1817,116 @@ public class CatalogDatabase implements Closeable {
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,
+ * Return a VNF Module List 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 vnfModuleType
+ * @parm modelCustomizationUuid
+ * @param asdcServiceModelVersion
+ * @param modelVersion
+ * @param action
+ * @return VfModule list
+ */
+ public List<VfModule> getVfModule (String vfModuleType, String modelCustomizationUuid, String asdcServiceModelVersion, String modelVersion, String action) {
+ StringBuilder hql;
+ Query query;
+ if(modelCustomizationUuid != null){
+ hql = new StringBuilder ("FROM VfModule WHERE modelCustomizationUuid = :modelCustomizationUuid AND version = :version");
+
+ LOGGER.debug ("Catalog database - get VF MODULE with type " + vfModuleType + ", asdcServiceModelVersion " + asdcServiceModelVersion + ", modelVersion " + modelVersion);
+
+ query = getSession ().createQuery (hql.toString ());
+ query.setParameter ("modelCustomizationUuid", modelCustomizationUuid);
+ query.setParameter ("version", asdcServiceModelVersion);
+ }else{
+ hql = new StringBuilder ("FROM VfModule WHERE type = :type AND version = :version AND modelVersion = :modelVersion");
+
+ LOGGER.debug ("Catalog database - get VF MODULE with type " + vfModuleType + ", asdcServiceModelVersion " + asdcServiceModelVersion + ", modelVersion " + modelVersion);
+
+ query = getSession ().createQuery (hql.toString ());
+ query.setParameter (TYPE, vfModuleType);
+ query.setParameter ("version", asdcServiceModelVersion);
+ query.setParameter ("modelVersion", modelVersion);
+ }
+
+ @SuppressWarnings("unchecked")
+ List <VfModule> resultList = query.list ();
+ return resultList;
+ }
+
+ /**
+ * Return a VNF COMPONENTSrecipe that matches a given VNF_TYPE, VF_MODULE_MODEL_NAME,
+ * 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
+ * @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");
-
+ public VnfComponentsRecipe getVnfComponentsRecipe (String vnfType, String vfModuleModelName, String modelCustomizationUuid, String asdcServiceModelVersion, String modelVersion, String action) {
+ String vfModuleType = vnfType + "::" + vfModuleModelName;
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);
-
+ List <VfModule> resultList = getVfModule(vfModuleType, modelCustomizationUuid, asdcServiceModelVersion, modelVersion, action);
+
+ if (resultList.isEmpty ()) {
+ LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. VF Module Entry not found", "CatalogDB", "getVnfComponentsRecipe", null);
+ return null;
+ }
+
+ 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 <VfModule> resultList = query.list ();
+ 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 a VNF COMPONENTSrecipe that matches a given VNF_TYPE, VF_MODULE_MODEL_NAME,
+ * ASDC_SERVICE_MODEL_VERSION, MODEL_VERSION, and ACTION
+ * first query VF_MODULE table by type, and then use the ID to query
+ * VNF_COMPONENTS_RECIPE by VF_MODULE_ID and ACTION
+ *
+ * @param vnfType
+ * @parm vfModuleModelName
+ * @param action
+ * @return VnfRecipe object or null if none found
+ */
+ public VnfComponentsRecipe getVnfComponentsRecipeByVfModule(List <VfModule> resultList, String action) {
+ long startTime = System.currentTimeMillis ();
if (resultList.isEmpty ()) {
LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. VF Module Entry not found", "CatalogDB", "getVnfComponentsRecipe", null);
@@ -1000,8 +1964,8 @@ public class CatalogDatabase implements Closeable {
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;
+ 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);
}
@@ -1472,21 +2436,116 @@ public class CatalogDatabase implements Closeable {
LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "saveOrUpdateVnfResource", null);
}
}
-
+
+ public void saveAllottedResourceCustomization (AllottedResourceCustomization resourceCustomization) {
+ long startTime = System.currentTimeMillis ();
+ LOGGER.debug ("Catalog database - save Allotted Resource with Name " + resourceCustomization.getModelName());
+ try {
+ List<AllottedResourceCustomization> allottedResourcesList = getAllAllottedResourcesByArModelCustomizationUuid(resourceCustomization.getModelCustomizationUuid());
+
+ if(allottedResourcesList.size() == 0){
+ this.getSession ().save(resourceCustomization);
+ }
+
+ } finally {
+ LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "saveOrUpdateAllottedResourceCustomization", null);
+ }
+ }
+
+ public void saveNetworkResourceCustomization (NetworkResourceCustomization networkResourceCustomization) throws RecordNotFoundException {
+ long startTime = System.currentTimeMillis ();
+ LOGGER.debug ("Catalog database - save Network Resource Customization with Network Name " + networkResourceCustomization.getModelName());
+ try {
+ // Check if NetworkResourceCustomzation record already exists. If so, skip saving it.
+ List<NetworkResourceCustomization> networkResourceCustomizationList = getAllNetworksByNetworkModelCustomizationUuid(networkResourceCustomization.getModelCustomizationUuid());
+ // Do any matching customization records exist?
+ if(networkResourceCustomizationList.size() == 0){
+
+ // Retreive the record from the Network_Resource table associated to the Customization record based on ModelName
+ NetworkResource networkResource = getNetworkResource(networkResourceCustomization.getModelName());
+
+ if(networkResource == null){
+ throw new RecordNotFoundException("No record found in NETWORK_RESOURCE table for model name " + networkResourceCustomization.getModelName());
+ }
+
+ networkResourceCustomization.setNetworkResourceId(networkResource.getId());
+
+ this.getSession ().save(networkResourceCustomization);
+ }
+
+
+ } finally {
+ LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "saveNetworkResourceCustomization", null);
+ }
+ }
+
+ public void saveServiceToNetworks (ServiceToNetworks serviceToNetworks) {
+ long startTime = System.currentTimeMillis ();
+ LOGGER.debug ("Catalog database - save to ServiceToNetworks table with NetworkModelCustomizationUUID of " + serviceToNetworks.getNetworkModelCustomizationUuid() + " and ServiceModelUUID of " + serviceToNetworks.getServiceModelUuid());
+ try {
+ this.getSession ().save(serviceToNetworks);
+
+ } finally {
+ LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "saveNetworkResourceCustomization", null);
+ }
+ }
+
+ public void saveServiceToAllottedResources (ServiceToAllottedResources serviceToAllottedResources) {
+ long startTime = System.currentTimeMillis ();
+ LOGGER.debug ("Catalog database - save to serviceToAllottedResources table with ARModelCustomizationUUID of " + serviceToAllottedResources.getArModelCustomizationUuid() + " and ServiceModelUUID of " + serviceToAllottedResources.getServiceModelUuid());
+ try {
+ this.getSession ().save(serviceToAllottedResources);
+
+ } finally {
+ LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "saveServiceToAllottedResources", null);
+ }
+ }
+
public void saveService (Service service) {
long startTime = System.currentTimeMillis ();
- LOGGER.debug ("Catalog database - save Service with ServiceName/Version/serviceUUID(SERVICE_NAME_VERSION_ID)" + service.getServiceName()+"/"+service.getServiceVersion()+"/"+service.getServiceNameVersionId());
+ LOGGER.debug ("Catalog database - save Service with ServiceName/Version/serviceUUID(SERVICE_NAME_VERSION_ID)" + service.getServiceName()+"/"+service.getVersion()+"/"+service.getServiceNameVersionId());
try {
- Service serviceDB = this.getServiceByUUID(service.getServiceNameVersionId());
+ Service serviceInvariantDB = null;
+ // Retrieve existing service record by nameVersionId
+ Service serviceDB = this.getServiceByUUID(service.getServiceNameVersionId());
if (serviceDB == null) {
- this.getSession ().save (service);
+ // Check to see if a record with the same modelInvariantId already exists. This tells us that a previous version exists and we can copy its recipe Record for the new service record.
+ serviceInvariantDB = this.getServiceByInvariantUUID(service.getModelInvariantUUID());
+ // Save the new Service record
+ this.getSession ().save (service);
}
-
+
+ if(serviceInvariantDB != null){ // existing modelInvariantId was found.
+ // copy the recipe record with the matching invariant id. We will duplicate this for the new service record
+ List<ServiceRecipe> serviceRecipes = getServiceRecipes(serviceInvariantDB.getId());
+
+ if(serviceRecipes != null && serviceRecipes.size() > 0){
+ for(ServiceRecipe serviceRecipe : serviceRecipes){
+ if(serviceRecipe != null){
+ // Fetch the service record that we just added. We do this so we can extract its Id column value, this will be the foreign key we use in the service recipe table.
+ Service newService = this.getServiceByUUID(service.getServiceNameVersionId());
+ // Create a new ServiceRecipe record based on the existing one we just copied from the DB.
+ ServiceRecipe newServiceRecipe = new ServiceRecipe();
+ newServiceRecipe.setAction(serviceRecipe.getAction());
+ newServiceRecipe.setDescription(serviceRecipe.getDescription());
+ newServiceRecipe.setOrchestrationUri(serviceRecipe.getOrchestrationUri());
+ newServiceRecipe.setRecipeTimeout(serviceRecipe.getRecipeTimeout());
+ newServiceRecipe.setServiceParamXSD(serviceRecipe.getServiceParamXSD());
+ newServiceRecipe.setServiceId(newService.getId());
+ newServiceRecipe.setVersion(serviceRecipe.getVersion());
+ // Save the new recipe record in the service_recipe table and associate it to the new service record that we just added.
+ this.getSession ().save (newServiceRecipe);
+ }
+ }
+ }
+
+ }
+
} finally {
LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "saveOrUpdateService", null);
}
}
-
+
public void saveOrUpdateVfModule (VfModule vfModule) {
long startTime = System.currentTimeMillis ();
LOGGER.debug ("Catalog database - save VNF Module with VF Model Name " + vfModule.getModelName());
@@ -1497,9 +2556,9 @@ public class CatalogDatabase implements Closeable {
} else {
this.getSession ().save (vfModule);
}
-
+
} finally {
- LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "saveOrUpdateVfModule", null);
+ LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "saveOrUpdateVfModule", null);
}
}
@@ -1511,21 +2570,21 @@ public class CatalogDatabase implements Closeable {
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) {
+ if (getNestedHeatTemplate(parentTemplateId,childTemplate.getId()) == null) {
HeatNestedTemplate nestedTemplate = new HeatNestedTemplate ();
nestedTemplate.setParentTemplateId (parentTemplateId);
nestedTemplate.setChildTemplateId (childTemplate.getId ());
@@ -1536,7 +2595,7 @@ public class CatalogDatabase implements Closeable {
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
@@ -1571,8 +2630,8 @@ public class CatalogDatabase implements Closeable {
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);
@@ -1582,7 +2641,7 @@ public class CatalogDatabase implements Closeable {
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 "
@@ -1593,7 +2652,7 @@ public class CatalogDatabase implements Closeable {
// asdc_heat_files_save
this.getSession ().save (childFile);
-
+
} else {
/* replaced 'heatFiles' by 'childFile'
Based on following comment:
@@ -1606,7 +2665,7 @@ public class CatalogDatabase implements Closeable {
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 "
@@ -1616,14 +2675,14 @@ public class CatalogDatabase implements Closeable {
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
@@ -1662,21 +2721,21 @@ public class CatalogDatabase implements Closeable {
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
+ * @param action
* @return NetworkRecipe object or null if none found
*/
public NetworkRecipe getNetworkRecipe (String networkType, String action) {
@@ -1689,21 +2748,21 @@ public class CatalogDatabase implements Closeable {
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);
@@ -1711,6 +2770,40 @@ public class CatalogDatabase implements Closeable {
}
/**
+ * Return a Network Resource that matches the Network Customization defined by given MODEL_CUSTOMIZATION_UUID
+ *
+ * @param networkType
+ * @param action
+ * @param serviceType
+ * @return NetworkRecipe object or null if none found
+ */
+ public NetworkResource getNetworkResourceByModelCustUuid(String modelCustomizationUuid) {
+
+ long startTime = System.currentTimeMillis ();
+ LOGGER.debug ("Catalog database - get network resource with modelCustomizationUuid " + modelCustomizationUuid);
+
+ try {
+ String hql = "select n FROM NetworkResource n, NetworkResourceCustomization c WHERE n.id=c.networkResourceId and c.modelCustomizationUuid = :modelCustomizationUuid";
+ Query query = getSession ().createQuery (hql);
+ query.setParameter (MODEL_CUSTOMIZATION_UUID, modelCustomizationUuid);
+
+ @SuppressWarnings("unchecked")
+ List <NetworkResource> resultList = query.list ();
+
+ if (resultList.isEmpty ()) {
+ return null;
+ }
+
+ Collections.sort (resultList, new MavenLikeVersioningComparator ());
+ Collections.reverse (resultList);
+
+ return resultList.get (0);
+ } finally {
+ LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getNetworkResourceBySvcNtwkRsrc", null);
+ }
+ }
+
+ /**
* Return a VnfComponents recipe that matches a given VNF_TYPE, VNF_COMPONENT_TYPE, ACTION, and, if specified,
* SERVICE_TYPE
*
@@ -1757,24 +2850,24 @@ public class CatalogDatabase implements Closeable {
}
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
+ * @param action
* @return VnfComponentsRecipe object or null if none found
*/
public VnfComponentsRecipe getVnfComponentsRecipeByVfModuleId (String vfModuleId,
String vnfComponentType,
- String action) {
+ String action) {
long startTime = System.currentTimeMillis ();
LOGGER.debug ("Catalog database - get Vnf Component recipe with vfModuleId " + vfModuleId
@@ -1786,12 +2879,12 @@ public class CatalogDatabase implements Closeable {
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 ();
@@ -1800,7 +2893,7 @@ public class CatalogDatabase implements Closeable {
}
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);
@@ -1863,6 +2956,71 @@ public class CatalogDatabase implements Closeable {
}
}
+ /**
+ * Return a Model recipe that matches a given MODEL_TYPE, MODEL_VERSION_ID, ACTION
+ * Note: This method is not currently used but was retained in the event the
+ * architecture moves back to a MODEL/MODEL_RECIPE structure.
+ *
+ * @param modelType
+ * @param modelVersionId
+ * @param action
+ * @return ModelRecipe object or null if none found
+ */
+ public ModelRecipe getModelRecipe(String modelType,
+ String modelVersionId,
+ String action) {
+
+ long startTime = System.currentTimeMillis();
+ LOGGER.debug("Catalog database - get Model recipe with modelType=" + modelType
+ + " and modeVersionId=" + modelVersionId
+ + " and action=" + action);
+
+ try {
+ String hql;
+ // TBD - at some point it would be desirable to figure out how to do a HQL JOIN across
+ // the MODEL and MODEL_RECIPE tables in HQL instead of 2 separate queries.
+ // There seems to be 2 issues: formatting a hql query that executes successfully
+ // and then being able to generate a result that will fit into the ModelRecipe class.
+
+ // 1st query to get the Model record for the given MODEL_TYPE and MODEL_VERSION_ID
+ hql = "FROM Model WHERE modelType = :modelType AND modelVersionId = :modelVersionId";
+ Query query = getSession().createQuery(hql);
+ query.setParameter(MODEL_TYPE, modelType);
+ query.setParameter(MODEL_VERSION_ID, modelVersionId);
+
+ @SuppressWarnings("unchecked")
+ List<Model> modelResultList = query.list();
+ if (modelResultList.isEmpty()) {
+ LOGGER.debug("Catalog database - modelResultList is null");
+ return null;
+ }
+ Collections.sort(modelResultList, new MavenLikeVersioningComparator());
+ Collections.reverse(modelResultList);
+ LOGGER.debug("Catalog database - modelResultList contains " + modelResultList.get(0).toString());
+
+ // 2nd query to get the ModelRecipe record corresponding to the Model from the 1st query
+ hql = "FROM ModelRecipe WHERE modelId = :modelId AND action = :action";
+ query = getSession().createQuery(hql);
+ // The MODEL table 'id' field maps to the MODEL_RECIPE table 'MODEL_ID' field
+ query.setParameter(MODEL_ID, modelResultList.get(0).getId());
+ query.setParameter(ACTION, action);
+
+ @SuppressWarnings("unchecked")
+ List<ModelRecipe> recipeResultList = query.list();
+ if (recipeResultList.isEmpty()) {
+ LOGGER.debug("Catalog database - recipeResultList is null");
+ return null;
+ }
+ Collections.sort(recipeResultList, new MavenLikeVersioningComparator());
+ Collections.reverse(recipeResultList);
+ LOGGER.debug("Catalog database - recipeResultList contains " + recipeResultList.get(0).toString());
+
+ return recipeResultList.get(0);
+ } finally {
+ LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getModelRecipe", null);
+ }
+ }
+
/**
* Verify the health of the DB.
diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/HibernateUtilsCatalogDb.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/HibernateUtilsCatalogDb.java
new file mode 100644
index 0000000000..c4069be443
--- /dev/null
+++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/HibernateUtilsCatalogDb.java
@@ -0,0 +1,45 @@
+/*-
+ * ============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 org.openecomp.mso.db.HibernateUtils;
+import org.openecomp.mso.logger.MessageEnum;
+import org.openecomp.mso.logger.MsoLogger;
+import java.net.URL;
+
+public class HibernateUtilsCatalogDb extends HibernateUtils {
+
+ private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.GENERAL);
+
+ @Override
+ protected URL getHibernateConfigFile() {
+ try {
+ if ("MYSQL".equals (System.getProperty ("mso.db")) || "MARIADB".equals(System.getProperty("mso.db"))) {
+ return this.getClass().getClassLoader().getResource("hibernate-catalog-core-mysql.cfg.xml");
+ } else {
+ LOGGER.error (MessageEnum.APIH_DB_ACCESS_EXC_REASON, "DB Connection not specified to the JVM,choose either:-Dmso.db=MARIADB, -Dmso.db=MYSQL or -Dmso.container=AJSC", "", "", MsoLogger.ErrorCode.DataError , "DB Connection not specified to the JVM,choose either:-Dmso.db=MARIADB, -Dmso.db=MYSQL or -Dmso.container=AJSC");
+ return null;
+ }
+ } catch (Exception ex) {
+ LOGGER.error (MessageEnum.APIH_DB_ACCESS_EXC_REASON, ex.getMessage (), "", "", MsoLogger.ErrorCode.DataError , "Problem in getting DB connection type", ex);
+ return null;
+ }
+ }
+} \ No newline at end of file
diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/AllottedResourceCustomization.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/AllottedResourceCustomization.java
new file mode 100644
index 0000000000..21cef1ea9f
--- /dev/null
+++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/AllottedResourceCustomization.java
@@ -0,0 +1,123 @@
+/*-
+ * ============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 org.openecomp.mso.db.catalog.utils.MavenLikeVersioning;
+
+public class AllottedResourceCustomization extends MavenLikeVersioning {
+
+ private String modelCustomizationUuid;
+ private String modelUuid;
+ private String modelInvariantUuid;
+ private String modelVersion = null; // duplicate of version kept in parent class
+ private String modelName;
+ private String description;
+ private Timestamp created;
+ private String modelInstanceName;
+
+ public AllottedResourceCustomization() {
+ super();
+ }
+
+ public String getModelCustomizationUuid() {
+ return this.modelCustomizationUuid;
+ }
+ public void setModelCustomizationUuid(String modelCustomizationUuid) {
+ this.modelCustomizationUuid = modelCustomizationUuid;
+ }
+
+ public String getModelUuid() {
+ return this.modelUuid;
+ }
+ public void setModelUuid(String modelUuid) {
+ this.modelUuid = modelUuid;
+ }
+
+ public String getModelInvariantUuid() {
+ return this.modelInvariantUuid;
+ }
+ public void setModelInvariantUuid(String modelInvariantUuid) {
+ this.modelInvariantUuid = modelInvariantUuid;
+ }
+
+ public String getModelName() {
+ return this.modelName;
+ }
+ public void setModelName(String modelName) {
+ this.modelName = modelName;
+ }
+
+ public String getDescription() {
+ return this.description;
+ }
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public Timestamp getCreated() {
+ return this.created;
+ }
+ public void setCreated(Timestamp created) {
+ this.created = created;
+ }
+
+ public String getModelInstanceName() {
+ return this.modelInstanceName;
+ }
+ public void setModelInstanceName(String modelInstanceName) {
+ this.modelInstanceName = modelInstanceName;
+ }
+ public String getModelVersion() {
+ return this.modelVersion;
+ }
+ public void setModelVersion(String modelVersion) {
+ this.modelVersion = modelVersion;
+ }
+
+ @Override
+ public String toString () {
+ StringBuffer sb = new StringBuffer();
+ sb.append("modelName=");
+ sb.append(this.modelName);
+ sb.append(",modelVersion=");
+ sb.append(this.modelVersion);
+ sb.append(",version=");
+ sb.append(this.version);
+ sb.append(",modelUuid=");
+ sb.append(this.modelUuid);
+ sb.append(",modelInvariantUuid=");
+ sb.append(this.modelInvariantUuid);
+ sb.append(",modelCustomizationUuid=");
+ sb.append(this.modelCustomizationUuid);
+ sb.append(",modelInstanceName=");
+ sb.append(this.modelInstanceName);
+ sb.append(",description=");
+ sb.append(this.description);
+ sb.append(",modelInstanceName=");
+ sb.append(this.modelInstanceName);
+ sb.append(",created=");
+ sb.append(this.created);
+
+ return sb.toString();
+ }
+
+}
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
index 69db27e989..a920375bcd 100644
--- 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
@@ -7,9 +7,9 @@
* 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.
@@ -35,9 +35,10 @@ public class HeatEnvironment extends MavenLikeVersioning {
private String asdcUuid;
private String asdcResourceName;
private String asdcLabel;
+ private String artifactChecksum;
private Timestamp created;
-
+
public HeatEnvironment() {}
public int getId() {
@@ -92,8 +93,15 @@ public class HeatEnvironment extends MavenLikeVersioning {
this.asdcLabel = asdcLabel;
}
+ public String getArtifactChecksum() {
+ return artifactChecksum;
+ }
- /**
+ public void setArtifactChecksum(String artifactChecksum) {
+ this.artifactChecksum = artifactChecksum;
+ }
+
+ /**
* @return the asdcResourceName
*/
public String getAsdcResourceName () {
@@ -115,7 +123,7 @@ public class HeatEnvironment extends MavenLikeVersioning {
public void setCreated(Timestamp created) {
this.created = created;
}
-
+
@Override
public String toString () {
StringBuffer sb = new StringBuffer();
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
index a1b6f228e1..d379c2471a 100644
--- 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
@@ -7,9 +7,9 @@
* 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.
@@ -36,38 +36,39 @@ public class HeatFiles extends MavenLikeVersioning {
private String asdcUuid;
private String asdcLabel;
private String asdcResourceName;
-
+ private String artifactChecksum;
+
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;
}
@@ -82,7 +83,7 @@ public class HeatFiles extends MavenLikeVersioning {
public void setCreated(Timestamp created) {
this.created = created;
}
-
+
public String getAsdcUuid() {
return this.asdcUuid;
}
@@ -103,6 +104,14 @@ public class HeatFiles extends MavenLikeVersioning {
this.asdcResourceName = asdcResourceName;
}
+ public String getArtifactChecksum() {
+ return artifactChecksum;
+ }
+
+ public void setArtifactChecksum(String artifactChecksum) {
+ this.artifactChecksum = artifactChecksum;
+ }
+
@Override
public String toString () {
StringBuffer sb = new StringBuffer();
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
index a80fa598b9..5762837bfb 100644
--- 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
@@ -7,9 +7,9 @@
* 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.
@@ -46,9 +46,10 @@ public class HeatTemplate extends MavenLikeVersioning {
private String asdcUuid;
private String asdcResourceName;
private String asdcLabel;
-
+ private String artifactChecksum;
+
private Timestamp created;
-
+
public enum TemplateStatus {
PARENT, CHILD, PARENT_COMPLETE
}
@@ -103,7 +104,7 @@ public class HeatTemplate extends MavenLikeVersioning {
public void setParameters (Set <HeatTemplateParam> parameters) {
this.parameters = parameters;
}
-
+
public String getDescription() {
return description;
}
@@ -131,7 +132,7 @@ public class HeatTemplate extends MavenLikeVersioning {
} catch (Exception e) {
LOGGER.debug ("Error reading template file " + templatePath, e);
}
-
+
return body;
}
@@ -150,7 +151,7 @@ public class HeatTemplate extends MavenLikeVersioning {
public void setAsdcUuid(String asdcUuidp) {
this.asdcUuid = asdcUuidp;
}
-
+
public String getAsdcResourceName() {
return asdcResourceName;
}
@@ -164,8 +165,15 @@ public class HeatTemplate extends MavenLikeVersioning {
public void setAsdcLabel(String asdcLabel) {
this.asdcLabel = asdcLabel;
}
-
- public Timestamp getCreated() {
+
+ public String getArtifactChecksum() {
+ return artifactChecksum;
+ }
+
+ public void setArtifactChecksum(String artifactChecksum) {
+ this.artifactChecksum = artifactChecksum;
+ }
+ public Timestamp getCreated() {
return created;
}
@@ -197,7 +205,7 @@ public class HeatTemplate extends MavenLikeVersioning {
sb.append (",created=");
sb.append (DateFormat.getInstance().format(created));
}
-
+
if (parameters != null && !parameters.isEmpty ()) {
sb.append (",params=[");
diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/Model.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/Model.java
new file mode 100644
index 0000000000..51153c912b
--- /dev/null
+++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/Model.java
@@ -0,0 +1,198 @@
+/*-
+ * ============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 Model extends MavenLikeVersioning {
+ private int id;
+ private String modelCustomizationId;
+ private String modelCustomizationName;
+ private String modelInvariantId;
+ private String modelName;
+ private String modelType;
+ private String modelVersion;
+ private String modelVersionId;
+ private Timestamp created;
+ private Map<String,ServiceRecipe> recipes;
+
+ /**
+ * @return the id
+ */
+ public int getId() {
+ return id;
+ }
+
+ /**
+ * @param id the id to set
+ */
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ /**
+ * @return the modelCustomizationId
+ */
+ public String getModelCustomizationId() {
+ return modelCustomizationId;
+ }
+
+ /**
+ * @param modelCustomizationId the modelCustomizationId to set
+ */
+ public void setModelCustomizationId(String modelCustomizationId) {
+ this.modelCustomizationId = modelCustomizationId;
+ }
+
+ /**
+ * @return the modelCustomizationName
+ */
+ public String getModelCustomizationName() {
+ return modelCustomizationName;
+ }
+
+ /**
+ * @param modelCustomizationName the modelCustomizationName to set
+ */
+ public void setModelCustomizationName(String modelCustomizationName) {
+ this.modelCustomizationName = modelCustomizationName;
+ }
+
+ /**
+ * @return the modelInvariantId
+ */
+ public String getModelInvariantId() {
+ return modelInvariantId;
+ }
+
+ /**
+ * @param modelInvariantId the modelInvariantId to set
+ */
+ public void setModelInvariantId(String modelInvariantId) {
+ this.modelInvariantId = modelInvariantId;
+ }
+
+ /**
+ * @return the modelName
+ */
+ public String getModelName() {
+ return modelName;
+ }
+
+ /**
+ * @param modelName the modelName to set
+ */
+ public void setModelName(String modelName) {
+ this.modelName = modelName;
+ }
+
+ /**
+ * @return the modelType
+ */
+ public String getModelType() {
+ return modelType;
+ }
+
+ /**
+ * @param modelType the modelType to set
+ */
+ public void setModelType(String modelType) {
+ this.modelType = modelType;
+ }
+
+ /**
+ * @return the modelVersion
+ */
+ public String getModelVersion() {
+ return modelVersion;
+ }
+
+ /**
+ * @param modelVersion the modelVersion to set
+ */
+ public void setModelVersion(String modelVersion) {
+ this.modelVersion = modelVersion;
+ }
+
+ /**
+ * @return the modelVersionId
+ */
+ public String getModelVersionId() {
+ return modelVersionId;
+ }
+
+ /**
+ * @param modelVersionId the modelVersionId to set
+ */
+ public void setModelVersionId(String modelVersionId) {
+ this.modelVersionId = modelVersionId;
+ }
+
+ /**
+ * @return the created
+ */
+ public Timestamp getCreated() {
+ return created;
+ }
+
+ /**
+ * @param created the created to set
+ */
+ public void setCreated(Timestamp created) {
+ this.created = created;
+ }
+
+ /**
+ * @return the recipes
+ */
+ public Map<String, ServiceRecipe> getRecipes() {
+ return recipes;
+ }
+
+ /**
+ * @param recipes the recipes to set
+ */
+ public void setRecipes(Map<String, ServiceRecipe> recipes) {
+ this.recipes = recipes;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("Model: ");
+ sb.append("modelCustomizationId=" + modelCustomizationId);
+ sb.append(",modelCustomizationName=" + modelCustomizationName);
+ sb.append(",modelInvariantId=" + modelInvariantId);
+ sb.append(",modelName=" + modelName);
+ sb.append(",modelType=" + modelType);
+ sb.append(",modelVersion=" + modelVersion);
+ sb.append(",modelVersionId=" + modelVersionId);
+ if (created != null) {
+ sb.append (",created=");
+ sb.append (DateFormat.getInstance().format(created));
+ }
+ return sb.toString();
+ }
+}
diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ModelRecipe.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ModelRecipe.java
new file mode 100644
index 0000000000..83fb773a8c
--- /dev/null
+++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ModelRecipe.java
@@ -0,0 +1,180 @@
+/*-
+ * ============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 ModelRecipe extends MavenLikeVersioning {
+ private int id;
+ private Integer modelId;
+ private String action;
+ private String schemaVersion;
+ private String description;
+ private String orchestrationUri;
+ private String modelParamXSD;
+ private Integer recipeTimeout;
+ private Timestamp created;
+
+ /**
+ * @return the id
+ */
+ public int getId() {
+ return id;
+ }
+
+ /**
+ * @param id the id to set
+ */
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ /**
+ * @return the modelId
+ */
+ public Integer getModelId() {
+ return modelId;
+ }
+
+ /**
+ * @param modelId the modelId to set
+ */
+ public void setModelId(Integer modelId) {
+ this.modelId = modelId;
+ }
+
+ /**
+ * @return the action
+ */
+ public String getAction() {
+ return action;
+ }
+
+ /**
+ * @param action the action to set
+ */
+ public void setAction(String action) {
+ this.action = action;
+ }
+
+ /**
+ * @return the versionStr
+ */
+ public String getSchemaVersion() {
+ return schemaVersion;
+ }
+
+ /**
+ * @param versionStr the versionStr to set
+ */
+ public void setSchemaVersion(String schemaVersion) {
+ this.schemaVersion = schemaVersion;
+ }
+
+ /**
+ * @return the description
+ */
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * @param description the description to set
+ */
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ /**
+ * @return the orchestrationUri
+ */
+ public String getOrchestrationUri() {
+ return orchestrationUri;
+ }
+
+ /**
+ * @param orchestrationUri the orchestrationUri to set
+ */
+ public void setOrchestrationUri(String orchestrationUri) {
+ this.orchestrationUri = orchestrationUri;
+ }
+
+ /**
+ * @return the modelParamXSD
+ */
+ public String getModelParamXSD() {
+ return modelParamXSD;
+ }
+
+ /**
+ * @param modelParamXSD the modelParamXSD to set
+ */
+ public void setModelParamXSD(String modelParamXSD) {
+ this.modelParamXSD = modelParamXSD;
+ }
+
+ /**
+ * @return the recipeTimeout
+ */
+ public Integer getRecipeTimeout() {
+ return recipeTimeout;
+ }
+
+ /**
+ * @param recipeTimeout the recipeTimeout to set
+ */
+ public void setRecipeTimeout(Integer recipeTimeout) {
+ this.recipeTimeout = recipeTimeout;
+ }
+
+ /**
+ * @return the created
+ */
+ public Timestamp getCreated() {
+ return created;
+ }
+
+ /**
+ * @param created the created to set
+ */
+ public void setCreated(Timestamp created) {
+ this.created = created;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("ModelRecipe: ");
+ sb.append("modelId=" + modelId.toString());
+ sb.append(",action=" + action);
+ sb.append(",schemaVersion=" + schemaVersion);
+ sb.append(",orchestrationUri=" + orchestrationUri);
+ sb.append(",modelParamXSD=" + modelParamXSD);
+ sb.append(",recipeTimeout=" + recipeTimeout.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/NetworkResourceCustomization.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/NetworkResourceCustomization.java
new file mode 100644
index 0000000000..0c49f1b1a4
--- /dev/null
+++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/NetworkResourceCustomization.java
@@ -0,0 +1,140 @@
+/*-
+ * ============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 org.openecomp.mso.db.catalog.utils.MavenLikeVersioning;
+
+public class NetworkResourceCustomization extends MavenLikeVersioning{
+
+ private String modelCustomizationUuid;
+ private String modelName;
+ private String modelInstanceName;
+ private String modelUuid;
+ private String modelVersion;
+ private String modelInvariantUuid;
+ private int networkResourceId = 0;
+ private Timestamp created;
+
+ // These fields are not in the table directly - but I'm adding them here for storage in the objects we're dealing with
+ private NetworkResource networkResource = null;
+ private String networkType = null;
+
+ public NetworkResourceCustomization() {
+ super();
+ }
+
+ public int getNetworkResourceId() {
+ return this.networkResourceId;
+ }
+ public void setNetworkResourceId(int networkResourceId) {
+ this.networkResourceId = networkResourceId;
+ }
+
+ public String getModelUuid() {
+ return this.modelUuid;
+ }
+ public void setModelUuid(String modelUuid) {
+ this.modelUuid = modelUuid;
+ }
+
+ public String getModelInvariantUuid() {
+ return this.modelInvariantUuid;
+ }
+ public void setModelInvariantUuid(String modelInvariantUuid) {
+ this.modelInvariantUuid = modelInvariantUuid;
+ }
+
+ public String getModelVersion() {
+ return this.modelVersion;
+ }
+ public void setModelVersion(String modelVersion) {
+ this.modelVersion = modelVersion;
+ }
+
+ public String getModelCustomizationUuid() {
+ return this.modelCustomizationUuid;
+ }
+ public void setModelCustomizationUuid(String modelCustomizationUuid) {
+ this.modelCustomizationUuid = modelCustomizationUuid;
+ }
+
+ public String getModelInstanceName() {
+ return this.modelInstanceName;
+ }
+ public void setModelInstanceName(String modelInstanceName) {
+ this.modelInstanceName = modelInstanceName;
+ }
+
+ public String getModelName() {
+ return this.modelName;
+ }
+ public void setModelName(String modelName) {
+ this.modelName = modelName;
+ }
+
+ public NetworkResource getNetworkResource() {
+ return this.networkResource;
+ }
+ public void setNetworkResource(NetworkResource networkResource) {
+ this.networkResource = networkResource;
+ }
+
+ public String getNetworkType() {
+ return this.networkType;
+ }
+ public void setNetworkType(String networkType) {
+ this.networkType = networkType;
+ }
+ public Timestamp getCreated() {
+ return this.created;
+ }
+ public void setCreated(Timestamp timestamp) {
+ this.created = timestamp;
+ }
+
+
+ @Override
+ public String toString () {
+ StringBuffer sb = new StringBuffer();
+ sb.append("modelName=");
+ sb.append(this.modelName);
+ sb.append("modelUuid=");
+ sb.append(this.modelUuid);
+ sb.append("modelUuid=");
+ sb.append(this.modelUuid);
+ sb.append("modelInvariantUuid=");
+ sb.append(this.modelInvariantUuid);
+ sb.append("modelVersion=");
+ sb.append(this.modelVersion);
+ sb.append("modelCustomizationUuid=");
+ sb.append(this.modelCustomizationUuid);
+ sb.append("modelInstanceName=");
+ sb.append(this.modelInstanceName);
+ sb.append("networkResourceId=");
+ sb.append(this.networkResourceId);
+ sb.append("networkType=");
+ sb.append(this.networkType);
+
+ return sb.toString();
+ }
+
+} \ No newline at end of file
diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceMacroHolder.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceMacroHolder.java
new file mode 100644
index 0000000000..01369c4ecd
--- /dev/null
+++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceMacroHolder.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 org.openecomp.mso.db.catalog.beans.Service;
+import org.openecomp.mso.db.catalog.beans.VnfResource;
+import org.openecomp.mso.db.catalog.beans.VfModule;
+import java.util.ArrayList;
+
+/*
+ * A simple holder for Service and its associated elements:
+ * VnfResource, 1-n VfModule, Network TBD
+ */
+
+public class ServiceMacroHolder {
+
+ private Service service;
+ private ArrayList<VnfResource> vnfResources;
+ private ArrayList<NetworkResourceCustomization> networkResourceCustomizations;
+ private ArrayList<AllottedResourceCustomization> allottedResourceCustomizations;
+
+ public ServiceMacroHolder() {
+ super();
+ this.service = null;
+ this.vnfResources = new ArrayList<VnfResource>();
+ this.networkResourceCustomizations = new ArrayList<NetworkResourceCustomization>();
+ this.allottedResourceCustomizations = new ArrayList<AllottedResourceCustomization>();
+ }
+ public ServiceMacroHolder(Service service) {
+ this();
+ this.service = service;
+ }
+
+ public Service getService() {
+ return this.service;
+ }
+ public void setService(Service service) {
+ this.service = service;
+ }
+
+ public void setVnfResources(ArrayList<VnfResource> vnfResources) {
+ this.vnfResources = vnfResources;
+ }
+ public ArrayList<VnfResource> getVnfResources() {
+ return this.vnfResources;
+ }
+ public void addVnfResource(VnfResource vr) {
+ if (vr != null) {
+ if (this.vnfResources != null) {
+ this.vnfResources.add(vr);
+ } else {
+ this.vnfResources = new ArrayList<VnfResource>();
+ this.vnfResources.add(vr);
+ }
+ }
+ }
+
+ public void setNetworkResourceCustomization(ArrayList<NetworkResourceCustomization> networkResourceCustomizations) {
+ this.networkResourceCustomizations = networkResourceCustomizations;
+ }
+ public ArrayList<NetworkResourceCustomization> getNetworkResourceCustomization() {
+ return this.networkResourceCustomizations;
+ }
+ public void addNetworkResourceCustomization(NetworkResourceCustomization nrc) {
+ if (this.networkResourceCustomizations != null) {
+ this.networkResourceCustomizations.add(nrc);
+ } else {
+ this.networkResourceCustomizations = new ArrayList<NetworkResourceCustomization>();
+ this.networkResourceCustomizations.add(nrc);
+ }
+ }
+
+ public void setAllottedResourceCustomization(ArrayList<AllottedResourceCustomization> allottedResourceCustomizations) {
+ this.allottedResourceCustomizations = allottedResourceCustomizations;
+ }
+ public ArrayList<AllottedResourceCustomization> getAllottedResourceCustomization() {
+ return this.allottedResourceCustomizations;
+ }
+ public void addAllottedResourceCustomization(AllottedResourceCustomization arc) {
+ if (this.allottedResourceCustomizations != null) {
+ this.allottedResourceCustomizations.add(arc);
+ } else {
+ this.allottedResourceCustomizations = new ArrayList<AllottedResourceCustomization>();
+ this.allottedResourceCustomizations.add(arc);
+ }
+ }
+
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("ServicePlus: ");
+ if (this.service != null) {
+ sb.append("service: " + this.service.toString());
+ } else {
+ sb.append("service: null");
+ }
+ if (this.vnfResources != null && this.vnfResources.size() > 0) {
+ int i=0;
+ sb.append("VnfResources: ");
+ for (VnfResource vr : this.vnfResources) {
+ sb.append(", vnfResource[" + i++ + "]:" + vr.toString());
+ }
+ } else {
+ sb.append("none");
+ }
+ if (this.networkResourceCustomizations != null && this.networkResourceCustomizations.size() > 0) {
+ int i=0;
+ sb.append("NetworkResourceCustomizations:");
+ for (NetworkResourceCustomization nrc : this.networkResourceCustomizations) {
+ sb.append("NRC[" + i++ + "]: " + nrc.toString());
+ }
+ }
+ if (this.allottedResourceCustomizations != null && this.allottedResourceCustomizations.size() > 0) {
+ int i=0;
+ sb.append("AllottedResourceCustomizations:");
+ for (AllottedResourceCustomization arc : this.allottedResourceCustomizations) {
+ sb.append("ARC[" + i++ + "]: " + arc.toString());
+ }
+ }
+
+ return sb.toString();
+ }
+
+
+}
diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceRecipe.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceRecipe.java
index 53ec3ba278..cc203ff98d 100644
--- 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
@@ -7,9 +7,9 @@
* 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.
@@ -26,6 +26,9 @@ package org.openecomp.mso.db.catalog.beans;
import java.sql.Timestamp;
import java.text.DateFormat;
import org.openecomp.mso.db.catalog.utils.MavenLikeVersioning;
+import java.util.Date;
+import org.openecomp.mso.db.catalog.utils.MavenLikeVersioning;
+import org.openecomp.mso.logger.MsoLogger;
public class ServiceRecipe extends MavenLikeVersioning {
private int id;
@@ -36,9 +39,38 @@ public class ServiceRecipe extends MavenLikeVersioning {
private String serviceParamXSD;
private int recipeTimeout;
private Integer serviceTimeoutInterim;
-
+
private Timestamp created;
-
+
+
+ private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.GENERAL);
+
+ // This 'default' CTR is now needed for backward compatibility since a new CTR was added below
+ public ServiceRecipe() {
+ super();
+ }
+
+ // This CTR is needed by the HQL SELECT JOIN between the SERVICE and SERVICE_RECIPE tables
+ // in CatalogDatabase::getServiceRecipe()
+ public ServiceRecipe(int id, int serviceId, String action,
+ String description, String orchestrationUri,
+ String serviceParamXSD, int recipeTimeout,
+ int serviceTimeoutInterim, Date created) {
+ super();
+ LOGGER.debug("ServiceRecipe id=" + id + ", serviceId=" + serviceId + ", action=" + action + ", description=" + description +
+ ", orchestrationUri=" + orchestrationUri + ", serviceParamXSD=" + serviceParamXSD +
+ ", recipeTimeout=" + recipeTimeout + ", serviceTimeoutInterim=" + serviceTimeoutInterim + ", created=" + created);
+ this.id = id;
+ this.serviceId = serviceId;
+ this.action = action;
+ this.description = description;
+ this.orchestrationUri = orchestrationUri;
+ this.serviceParamXSD = serviceParamXSD;
+ this.recipeTimeout = recipeTimeout;
+ this.serviceTimeoutInterim = serviceTimeoutInterim;
+ long date = created.getTime();
+ this.created = new Timestamp(date);
+ }
public int getId() {
return id;
@@ -96,7 +128,7 @@ public class ServiceRecipe extends MavenLikeVersioning {
public void setServiceTimeoutInterim(Integer serviceTimeoutInterim) {
this.serviceTimeoutInterim = serviceTimeoutInterim;
}
-
+
public Timestamp getCreated() {
return created;
}
diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceToAllottedResources.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceToAllottedResources.java
new file mode 100644
index 0000000000..1fc93be6f5
--- /dev/null
+++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceToAllottedResources.java
@@ -0,0 +1,67 @@
+/*-
+ * ============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;
+import java.sql.Timestamp;
+
+public class ServiceToAllottedResources implements Serializable {
+
+ private String serviceModelUuid;
+ private String arModelCustomizationUuid;
+ private Timestamp created;
+
+ public static final long serialVersionUID = -1322322139926390329L;
+
+ public ServiceToAllottedResources() {
+ super();
+ }
+
+ public String getServiceModelUuid() {
+ return this.serviceModelUuid;
+ }
+ public void setServiceModelUuid(String serviceModelUuid) {
+ this.serviceModelUuid = serviceModelUuid;
+ }
+ public String getArModelCustomizationUuid() {
+ return this.arModelCustomizationUuid;
+ }
+ public void setArModelCustomizationUuid(String arModelCustomizationUuid) {
+ this.arModelCustomizationUuid = arModelCustomizationUuid;
+ }
+ public Timestamp getCreated() {
+ return this.created;
+ }
+ public void setCreated(Timestamp created) {
+ this.created = created;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("serviceModelUuid=");
+ sb.append(this.serviceModelUuid);
+ sb.append("arModelCustomizationUuid=");
+ sb.append(this.arModelCustomizationUuid);
+
+ return sb.toString();
+ }
+
+}
diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceToNetworks.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceToNetworks.java
new file mode 100644
index 0000000000..5ea171e93b
--- /dev/null
+++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceToNetworks.java
@@ -0,0 +1,68 @@
+/*-
+ * ============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;
+import java.sql.Timestamp;
+
+public class ServiceToNetworks implements Serializable {
+
+ // This maps to SERVICE.SERVICE_NAME_VERSION_ID / Service.serviceNameVersionId in SERVICE/Service table
+ private String serviceModelUuid;
+ // This maps to NETWORK_RESOURCE_CUSTOMIZATION.MODEL_CUSTOMIZATION_UUID / NetworkResourceCustomization.ModelCustomizationUuid
+ private String networkModelCustomizationUuid;
+ private Timestamp created;
+ public static final long serialVersionUID = -1322322139926390329L;
+
+ public ServiceToNetworks() {
+ super();
+ }
+
+ public String getServiceModelUuid() {
+ return this.serviceModelUuid;
+ }
+ public void setServiceModelUuid(String serviceModelUuid) {
+ this.serviceModelUuid = serviceModelUuid;
+ }
+
+ public String getNetworkModelCustomizationUuid() {
+ return this.networkModelCustomizationUuid;
+ }
+ public void setNetworkModelCustomizationUuid(String networkCustomizationUuid) {
+ this.networkModelCustomizationUuid = networkCustomizationUuid;
+ }
+
+ public Timestamp getCreated() {
+ return this.created;
+ }
+ public void setCreated(Timestamp timestamp) {
+ this.created = timestamp;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("ServiceToNetworks mapping: ");
+ sb.append("serviceModelUuid=" + this.serviceModelUuid);
+ sb.append(",networkModelCustomizationUuid=" + networkModelCustomizationUuid);
+ 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
index 505b3bba9a..a551ef864e 100644
--- 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
@@ -7,9 +7,9 @@
* 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.
@@ -28,7 +28,7 @@ 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;
@@ -40,35 +40,40 @@ public class VfModule extends MavenLikeVersioning {
private Integer volEnvironmentId;
private String description;
private String asdcUuid;
- private Timestamp created;
+ private Timestamp created;
private String modelInvariantUuid;
private String modelVersion;
-
+ private String modelCustomizationUuid = null;
+ private Integer minInstances;
+ private Integer maxInstances;
+ private Integer initialCount;
+ private String label;
+
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;
}
@@ -90,14 +95,14 @@ public class VfModule extends MavenLikeVersioning {
return true;
}
}
-
+
public Integer getTemplateId() {
return this.templateId;
}
public void setTemplateId(Integer templateId) {
this.templateId = templateId;
}
-
+
public Integer getEnvironmentId() {
return this.environmentId;
}
@@ -111,21 +116,21 @@ public class VfModule extends MavenLikeVersioning {
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;
}
@@ -133,7 +138,7 @@ public class VfModule extends MavenLikeVersioning {
public void setAsdcUuid(String asdcUuidp) {
this.asdcUuid = asdcUuidp;
}
-
+
public Timestamp getCreated() {
return created;
}
@@ -147,19 +152,49 @@ public class VfModule extends MavenLikeVersioning {
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 getModelCustomizationUuid() {
+ return this.modelCustomizationUuid;
+ }
+ public void setModelCustomizationUuid(String modelCustomizationUuid) {
+ this.modelCustomizationUuid = modelCustomizationUuid;
+ }
+ public Integer getMinInstances() {
+ return this.minInstances;
+ }
+ public void setMinInstances(Integer minInstances) {
+ this.minInstances = minInstances;
+ }
+ public Integer getMaxInstances() {
+ return this.maxInstances;
+ }
+ public void setMaxInstances(Integer maxInstances) {
+ this.maxInstances = maxInstances;
+ }
+ public Integer getInitialCount() {
+ return this.initialCount;
+ }
+ public void setInitialCount(Integer initialCount) {
+ this.initialCount = initialCount;
+ }
+ public String getLabel() {
+ return this.label;
+ }
+ public void setLabel(String label) {
+ this.label = label;
+ }
+
+ @Override
public String toString () {
StringBuffer buf = new StringBuffer();
-
+
buf.append("VF=");
buf.append(this.type);
buf.append(",modelName=");
@@ -184,12 +219,22 @@ public class VfModule extends MavenLikeVersioning {
buf.append(asdcUuid);
buf.append(",modelVersion=");
buf.append(this.modelVersion);
-
+ buf.append(",modelCustomizationUuid=");
+ buf.append(this.modelCustomizationUuid);
+ buf.append(",minInstances=");
+ buf.append(this.minInstances);
+ buf.append(",maxInstances=");
+ buf.append(this.maxInstances);
+ buf.append(",initialCount=");
+ buf.append(this.initialCount);
+ buf.append(",label=");
+ buf.append(this.label);
+
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/VnfResource.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfResource.java
index 60c7ef216e..72f143dcc0 100644
--- 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
@@ -7,9 +7,9 @@
* 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.
@@ -23,6 +23,7 @@ package org.openecomp.mso.db.catalog.beans;
import java.sql.Timestamp;
import java.text.DateFormat;
+import java.util.ArrayList;
import java.util.Map;
import org.openecomp.mso.db.catalog.utils.MavenLikeVersioning;
@@ -31,30 +32,35 @@ 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 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;
-
+ private String modelCustomizationUuid = null;
+
+ private ArrayList<VfModule> vfModules;
+
public VnfResource () {
+ super();
+ this.vfModules = new ArrayList<VfModule>();
}
public int getId () {
@@ -104,7 +110,7 @@ public class VnfResource extends MavenLikeVersioning {
public void setEnvironmentId (Integer environmentId) {
this.environmentId = environmentId;
}
-
+
public Map <String, HeatFiles> getHeatFiles () {
return this.heatFiles;
}
@@ -120,7 +126,7 @@ public class VnfResource extends MavenLikeVersioning {
public void setAsdcUuid(String asdcUuidp) {
this.asdcUuid = asdcUuidp;
}
-
+
public Timestamp getCreated() {
return created;
}
@@ -128,38 +134,38 @@ public class VnfResource extends MavenLikeVersioning {
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;
}
@@ -184,6 +190,29 @@ public class VnfResource extends MavenLikeVersioning {
this.serviceModelInvariantUUID = serviceModelInvariantUUID;
}
+ public String getModelCustomizationUuid() {
+ return this.modelCustomizationUuid;
+ }
+ public void setModelCustomizationUuid(String modelCustomizationUuid) {
+ this.modelCustomizationUuid = modelCustomizationUuid;
+ }
+
+ public ArrayList<VfModule> getVfModules() {
+ return this.vfModules;
+ }
+ public void setVfModules(ArrayList<VfModule> vfModules) {
+ this.vfModules = vfModules;
+ }
+ public void addVfModule(VfModule vfm) {
+ if (vfm != null) {
+ if (this.vfModules != null) {
+ this.vfModules.add(vfm);
+ } else {
+ this.vfModules = new ArrayList<VfModule>();
+ this.vfModules.add(vfm);
+ }
+ }
+ }
@Override
public String toString () {
StringBuffer buf = new StringBuffer();
@@ -214,11 +243,22 @@ public class VnfResource extends MavenLikeVersioning {
buf.append(this.modelName);
buf.append(",serviceModelInvariantUUID=");
buf.append(this.serviceModelInvariantUUID);
-
+ buf.append(",modelCustomizationUuid=");
+ buf.append(this.modelCustomizationUuid);
+
if (created != null) {
buf.append(",created=");
buf.append(DateFormat.getInstance().format(created));
}
+ if (this.vfModules != null && this.vfModules.size() > 0) {
+ buf.append("VfModules:");
+ int i=0;
+ for (VfModule vfm : this.vfModules) {
+ buf.append("vfModule[" + i++ + "]:" + vfm.toString());
+ }
+ } else {
+ buf.append("VfModules: NONE");
+ }
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
index c617a4a6f4..73a9f8eb00 100644
--- 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
@@ -7,9 +7,9 @@
* 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.
@@ -21,15 +21,16 @@
package org.openecomp.mso.db.catalog.utils;
+import java.io.Serializable;
/**
* This class is the base class for object that requires a Version in Catalog DB.
* The version is built on a string as ASDC provides a number like 1.2 or 2.0 ...
* This class supports also 1.2.3.4... (Maven like version)
- *
+ *
*
*/
-public class MavenLikeVersioning {
+public class MavenLikeVersioning implements Serializable {
protected String version;
diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/utils/RecordNotFoundException.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/utils/RecordNotFoundException.java
new file mode 100644
index 0000000000..d7f791005a
--- /dev/null
+++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/utils/RecordNotFoundException.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;
+
+/*
+* Exception of the ASDC controller.
+*/
+public class RecordNotFoundException extends Exception {
+
+ /**
+ * serialization id.
+ */
+ private static final long serialVersionUID = 8425657297510362736L;
+
+ /**
+ * @param message The message to dump
+ * @param cause The Throwable cause object
+ */
+ public RecordNotFoundException(final String message) {
+ super (message);
+
+ }
+
+ /**
+ * @param message The message to dump
+ * @param cause The Throwable cause object
+ */
+ public RecordNotFoundException(final String message, final Throwable cause) {
+ super (message, cause);
+
+ }
+}