summaryrefslogtreecommitdiffstats
path: root/mso-catalog-db/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'mso-catalog-db/src/main/java')
-rw-r--r--mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/CatalogDatabase.java306
1 files changed, 153 insertions, 153 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 dd60bc7d9c..0219e304cb 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
@@ -155,29 +155,29 @@ public class CatalogDatabase implements Closeable {
* @return A list of HeatTemplate objects
*/
@SuppressWarnings("unchecked")
- public List <HeatTemplate> getAllHeatTemplates () {
- long startTime = System.currentTimeMillis ();
- LOGGER.debug ("Catalog database - get all Heat templates");
+ public List <HeatTemplate> getAllHeatTemplates() {
+ long startTime = System.currentTimeMillis();
+ LOGGER.debug("Catalog database - get all Heat templates");
String hql = "FROM HeatTemplate";
- Query query = getSession ().createQuery (hql);
+ Query query = getSession().createQuery(hql);
- List <HeatTemplate> result = query.list ();
- LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getAllHeatTemplates", null);
+ List <HeatTemplate> result = query.list();
+ LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getAllHeatTemplates", null);
return result;
}
/**
* Fetch a specific Heat Template by ID.
*
- * @param templateId
+ * @param templateId template id
* @return HeatTemplate object or null if none found
*/
@Deprecated
- public HeatTemplate getHeatTemplate (int templateId) {
- long startTime = System.currentTimeMillis ();
+ public HeatTemplate getHeatTemplate(int templateId) {
+ long startTime = System.currentTimeMillis();
LOGGER.debug ("Catalog database - get Heat template with id " + templateId);
- HeatTemplate template = (HeatTemplate) getSession ().get (HeatTemplate.class, templateId);
+ HeatTemplate template = (HeatTemplate) getSession().get(HeatTemplate.class, templateId);
LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getHeatTemplate", null);
return template;
}
@@ -185,31 +185,31 @@ public class CatalogDatabase implements Closeable {
/**
* Return the newest version of a specific Heat Template (queried by Name).
*
- * @param templateName
+ * @param templateName template name
* @return HeatTemplate object or null if none found
*/
- public HeatTemplate getHeatTemplate (String templateName) {
+ public HeatTemplate getHeatTemplate(String templateName) {
- long startTime = System.currentTimeMillis ();
- LOGGER.debug ("Catalog database - get Heat template with name " + templateName);
+ long startTime = System.currentTimeMillis();
+ LOGGER.debug("Catalog database - get Heat template with name " + templateName);
String hql = "FROM HeatTemplate WHERE templateName = :template_name";
- Query query = getSession ().createQuery (hql);
- query.setParameter ("template_name", templateName);
+ Query query = getSession().createQuery (hql);
+ query.setParameter("template_name", templateName);
@SuppressWarnings("unchecked")
- List <HeatTemplate> resultList = query.list ();
+ List <HeatTemplate> resultList = query.list();
// See if something came back. Name is unique, so
if (resultList.isEmpty ()) {
LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. No template found", "CatalogDB", "getHeatTemplate", null);
return null;
}
- Collections.sort (resultList, new MavenLikeVersioningComparator ());
- Collections.reverse (resultList);
+ Collections.sort(resultList, new MavenLikeVersioningComparator());
+ Collections.reverse(resultList);
- LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getHeatTemplate", null);
- return resultList.get (0);
+ LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getHeatTemplate", null);
+ return resultList.get(0);
}
/**
@@ -219,29 +219,29 @@ public class CatalogDatabase implements Closeable {
* @param version
* @return HeatTemplate object or null if none found
*/
- public HeatTemplate getHeatTemplate (String templateName, String version) {
+ public HeatTemplate getHeatTemplate(String templateName, String version) {
- long startTime = System.currentTimeMillis ();
- LOGGER.debug ("Catalog database - get Heat template with name " + templateName
+ long startTime = System.currentTimeMillis();
+ LOGGER.debug("Catalog database - get Heat template with name " + templateName
+ " and version "
+ version);
String hql = "FROM HeatTemplate WHERE templateName = :template_name AND version = :version";
- Query query = getSession ().createQuery (hql);
- query.setParameter ("template_name", templateName);
- query.setParameter ("version", version);
+ Query query = getSession().createQuery(hql);
+ query.setParameter("template_name", templateName);
+ query.setParameter("version", version);
@SuppressWarnings("unchecked")
- List <HeatTemplate> resultList = query.list ();
+ List <HeatTemplate> resultList = query.list();
// See if something came back.
- if (resultList.isEmpty ()) {
- LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. No template found.", "CatalogDB", "getHeatTemplate", null);
+ if (resultList.isEmpty()) {
+ LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. No template found.", "CatalogDB", "getHeatTemplate", null);
return null;
}
// Name + Version is unique, so should only be one element
- LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getHeatTemplate", null);
- return resultList.get (0);
+ LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getHeatTemplate", null);
+ return resultList.get(0);
}
/**
@@ -266,10 +266,10 @@ public class CatalogDatabase implements Closeable {
*
* @param artifactUuid
* @return HeatTemplate object or null if none found
- */
+ */
public HeatTemplate getHeatTemplateByArtifactUuidRegularQuery(String artifactUuid) {
- long startTime = System.currentTimeMillis ();
- LOGGER.debug ("Catalog database - get Heat template (regular query) with artifactUuid " + artifactUuid);
+ long startTime = System.currentTimeMillis();
+ LOGGER.debug("Catalog database - get Heat template (regular query) with artifactUuid " + artifactUuid);
String hql = "FROM HeatTemplate WHERE artifactUuid = :artifactUuidValue";
HashMap<String, String> variables = new HashMap<>();
@@ -277,9 +277,9 @@ public class CatalogDatabase implements Closeable {
HeatTemplate template = (HeatTemplate) this.executeQuerySingleRow(hql, variables, true);
if (template == null) {
- LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "NotFound", "CatalogDB", "getHeatTemplateByArtifactUuidRegularQuery", null);
+ LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "NotFound", "CatalogDB", "getHeatTemplateByArtifactUuidRegularQuery", null);
} else {
- LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getHeatTemplateByArtifactUuidRegularQuery", null);
+ LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getHeatTemplateByArtifactUuidRegularQuery", null);
}
return template;
}
@@ -314,19 +314,18 @@ public class CatalogDatabase implements Closeable {
* @return HeatEnvironment object or null if none found
*/
public HeatEnvironment getHeatEnvironmentByArtifactUuid(String artifactUuid) {
- long startTime = System.currentTimeMillis ();
- LOGGER.debug ("Catalog database - get Heat Environment with artifactUuid " + artifactUuid);
+ long startTime = System.currentTimeMillis();
+ LOGGER.debug("Catalog database - get Heat Environment with artifactUuid " + artifactUuid);
String hql = "FROM HeatEnvironment WHERE artifactUuid = :artifactUuidValue";
Query query = getSession().createQuery(hql);
- query.setParameter ("artifactUuidValue", artifactUuid);
+ query.setParameter("artifactUuidValue", artifactUuid);
HeatEnvironment environment = null;
try {
- environment = (HeatEnvironment) query.uniqueResult ();
+ environment = (HeatEnvironment) query.uniqueResult();
} catch (org.hibernate.NonUniqueResultException nure) {
LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique row for Envt - data integrity error: artifactUuid='" + artifactUuid +"'", nure);
LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for heatEnvironment artifactUuid=" + artifactUuid, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for artifactUuid==" + artifactUuid);
- environment = null;
} catch (org.hibernate.HibernateException he) {
LOGGER.debug("Hibernate Exception - while searching for envt: artifactUuid='" + artifactUuid + "' " + he.getMessage());
LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching envt for artifactUuid=" + artifactUuid, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching envt for artifactUuid=" + artifactUuid);
@@ -352,11 +351,11 @@ public class CatalogDatabase implements Closeable {
*/
public Service getServiceByInvariantUUID (String modelInvariantUUID) {
- long startTime = System.currentTimeMillis ();
- LOGGER.debug ("Catalog database - get service with Invariant UUID " + 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 query = getSession().createQuery(hql);
query.setParameter ("model_invariant_uuid", modelInvariantUUID);
@SuppressWarnings("unchecked")
@@ -379,16 +378,16 @@ public class CatalogDatabase implements Closeable {
*/
public Service getService (String modelName) {
- long startTime = System.currentTimeMillis ();
- LOGGER.debug ("Catalog database - get service with name " + modelName);
+ long startTime = System.currentTimeMillis();
+ LOGGER.debug("Catalog database - get service with name " + modelName);
String hql = "FROM Service WHERE modelName = :MODEL_NAME";
- Query query = getSession ().createQuery (hql);
- query.setParameter ("MODEL_NAME", modelName);
+ Query query = getSession().createQuery(hql);
+ query.setParameter("MODEL_NAME", modelName);
Service service = null;
try {
- service = (Service) query.uniqueResult ();
+ service = (Service) query.uniqueResult();
} catch (org.hibernate.NonUniqueResultException nure) {
LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique row - data integrity error: modelName='" + modelName + "'");
LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for modelName=" + modelName, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for modelName=" + modelName);
@@ -413,8 +412,8 @@ public class CatalogDatabase implements Closeable {
public Service getServiceByModelUUID (String modelUUID) {
- long startTime = System.currentTimeMillis ();
- LOGGER.debug ("Catalog database - get service with Model UUID " + modelUUID);
+ long startTime = System.currentTimeMillis();
+ LOGGER.debug("Catalog database - get service with Model UUID " + modelUUID);
String hql = "FROM Service WHERE modelUUID = :MODEL_UUID";
HashMap<String, String> parameters = new HashMap<>();
@@ -463,25 +462,25 @@ public class CatalogDatabase implements Closeable {
LOGGER.debug ("Catalog database - get service modelUUID with id " + serviceNameVersionId);
String hql = "FROM Service WHERE MODEL_UUID = :MODEL_UUID and http_method = :http_method";
- query = getSession ().createQuery (hql);
- query.setParameter ("MODEL_UUID", serviceNameVersionId);
+ query = getSession().createQuery(hql);
+ query.setParameter("MODEL_UUID", serviceNameVersionId);
} else {
serviceId = map.get("serviceId");
serviceVersion = map.get("serviceVersion");
- LOGGER.debug ("Catalog database - get serviceId with id " + serviceId + " and serviceVersion with " + serviceVersion);
+ LOGGER.debug("Catalog database - get serviceId with id " + serviceId + " and serviceVersion with " + serviceVersion);
String hql = "FROM Service WHERE service_id = :service_id and service_version = :service_version and http_method = :http_method";
- query = getSession ().createQuery (hql);
- query.setParameter ("service_id", serviceId);
- query.setParameter ("service_version", serviceVersion);
+ query = getSession().createQuery(hql);
+ query.setParameter("service_id", serviceId);
+ query.setParameter("service_version", serviceVersion);
}
- query.setParameter ("http_method", httpMethod);
+ query.setParameter("http_method", httpMethod);
- long startTime = System.currentTimeMillis ();
+ long startTime = System.currentTimeMillis();
Service service = null;
try {
- service = (Service) query.uniqueResult ();
+ service = (Service) query.uniqueResult();
} catch (org.hibernate.NonUniqueResultException nure) {
LOGGER.debug("Non Unique Result Exception - data integrity error: service_id='" + serviceId + "', serviceVersion='" + serviceVersion + "'");
LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for service_id=" + serviceId + " and serviceVersion=" + serviceVersion, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for service_id=" + serviceId);
@@ -512,37 +511,37 @@ public class CatalogDatabase implements Closeable {
* @param modelName
* @return Service object or null if none found
*/
- public Service getServiceByModelName (String modelName){
+ public Service getServiceByModelName(String modelName){
- long startTime = System.currentTimeMillis ();
- LOGGER.debug ("Catalog database - get service with name " + modelName);
+ long startTime = System.currentTimeMillis();
+ LOGGER.debug("Catalog database - get service with name " + modelName);
String hql = "FROM Service WHERE modelName = :MODEL_NAME";
- Query query = getSession ().createQuery (hql);
- query.setParameter ("MODEL_NAME", modelName);
+ Query query = getSession().createQuery(hql);
+ query.setParameter("MODEL_NAME", modelName);
@SuppressWarnings("unchecked")
- List <Service> resultList = query.list ();
+ List <Service> resultList = query.list();
// See if something came back.
- if (resultList.isEmpty ()) {
- LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. Service not found", "CatalogDB", "getServiceByModelName", null);
+ if (resultList.isEmpty()) {
+ LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. Service not found", "CatalogDB", "getServiceByModelName", null);
return null;
}
- Collections.sort (resultList, new MavenLikeVersioningComparator ());
- Collections.reverse (resultList);
+ Collections.sort(resultList, new MavenLikeVersioningComparator ());
+ Collections.reverse(resultList);
- LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getServiceByModelName", null);
- return resultList.get (0);
+ LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getServiceByModelName", null);
+ return resultList.get(0);
}
public Service getServiceByVersionAndInvariantId(String modelInvariantId, String modelVersion) throws Exception {
- long startTime = System.currentTimeMillis ();
- LOGGER.debug ("Catalog database - get service with modelInvariantId: " + modelInvariantId + " and modelVersion: " + modelVersion);
+ 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 query = getSession().createQuery(hql);
+ query.setParameter("MODEL_INVARIANT_UUID", modelInvariantId);
query.setParameter("VERSION_STR", modelVersion);
Service result = null;
@@ -555,11 +554,11 @@ public class CatalogDatabase implements Closeable {
}
// See if something came back.
if (result==null) {
- LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. Service not found", "CatalogDB", "getServiceByVersionAndInvariantId", 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);
+ LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getServiceByVersionAndInvariantId", null);
return result;
}
@@ -615,67 +614,67 @@ public class CatalogDatabase implements Closeable {
* @param action *
* @return ServiceRecipe object or null if none found
*/
- public ServiceRecipe getServiceRecipeByServiceModelUuid (String serviceModelUuid, String action) {
+ public ServiceRecipe getServiceRecipeByServiceModelUuid(String serviceModelUuid, String action) {
StringBuilder hql;
if(action == null){
- hql = new StringBuilder ("FROM ServiceRecipe WHERE serviceModelUuid = :serviceModelUuid");
+ hql = new StringBuilder("FROM ServiceRecipe WHERE serviceModelUuid = :serviceModelUuid");
}else {
- hql = new StringBuilder ("FROM ServiceRecipe WHERE serviceModelUuid = :serviceModelUuid AND action = :action ");
+ hql = new StringBuilder("FROM ServiceRecipe WHERE serviceModelUuid = :serviceModelUuid AND action = :action ");
}
long startTime = System.currentTimeMillis ();
- LOGGER.debug ("Catalog database - get Service recipe with serviceModelUuid " + serviceModelUuid
+ LOGGER.debug("Catalog database - get Service recipe with serviceModelUuid " + serviceModelUuid
+ " and action "
+ action
);
- Query query = getSession ().createQuery (hql.toString ());
- query.setParameter ("serviceModelUuid", serviceModelUuid);
+ Query query = getSession().createQuery(hql.toString());
+ query.setParameter("serviceModelUuid", serviceModelUuid);
if(action != null){
- query.setParameter (ACTION, action);
+ query.setParameter(ACTION, action);
}
@SuppressWarnings("unchecked")
- List <ServiceRecipe> resultList = query.list ();
+ List <ServiceRecipe> resultList = query.list();
- if (resultList.isEmpty ()) {
- LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. Service recipe not found", "CatalogDB", "getServiceRecipe", null);
+ if (resultList.isEmpty()) {
+ LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. Service recipe not found", "CatalogDB", "getServiceRecipe", null);
return null;
}
- Collections.sort (resultList, new MavenLikeVersioningComparator ());
- Collections.reverse (resultList);
+ Collections.sort(resultList, new MavenLikeVersioningComparator());
+ Collections.reverse(resultList);
- LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getServiceRecipe", null);
- return resultList.get (0);
+ LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getServiceRecipe", null);
+ return resultList.get(0);
}
- public List<ServiceRecipe> getServiceRecipes (String serviceModelUuid) {
+ public List<ServiceRecipe> getServiceRecipes(String serviceModelUuid) {
StringBuilder hql;
- hql = new StringBuilder ("FROM ServiceRecipe WHERE serviceModelUUID = :serviceModelUUID");
+ hql = new StringBuilder("FROM ServiceRecipe WHERE serviceModelUUID = :serviceModelUUID");
- long startTime = System.currentTimeMillis ();
- LOGGER.debug ("Catalog database - get Service recipe with serviceModelUUID " + serviceModelUuid);
+ long startTime = System.currentTimeMillis();
+ LOGGER.debug("Catalog database - get Service recipe with serviceModelUUID " + serviceModelUuid);
- Query query = getSession ().createQuery (hql.toString ());
- query.setParameter ("serviceModelUUID", serviceModelUuid);
+ Query query = getSession().createQuery(hql.toString());
+ query.setParameter("serviceModelUUID", serviceModelUuid);
@SuppressWarnings("unchecked")
- List <ServiceRecipe> resultList = query.list ();
+ 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);
+ if (resultList.isEmpty()) {
+ LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. Service recipe not found", "CatalogDB", "getServiceRecipes", null);
return Collections.EMPTY_LIST;
}
- Collections.sort (resultList, new MavenLikeVersioningComparator ());
- Collections.reverse (resultList);
+ Collections.sort(resultList, new MavenLikeVersioningComparator());
+ Collections.reverse(resultList);
- LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getServiceRecipes", null);
+ LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getServiceRecipes", null);
return resultList;
}
@@ -734,48 +733,48 @@ public class CatalogDatabase implements Closeable {
*/
public VnfResource getVnfResource (String vnfType) {
- long startTime = System.currentTimeMillis ();
- LOGGER.debug ("Catalog database - get vnf resource with model_name " + vnfType);
+ long startTime = System.currentTimeMillis();
+ LOGGER.debug("Catalog database - get vnf resource with model_name " + vnfType);
String hql = "FROM VnfResource WHERE modelName = :vnf_name";
- Query query = getSession ().createQuery (hql);
- query.setParameter ("vnf_name", vnfType);
+ Query query = getSession().createQuery(hql);
+ query.setParameter("vnf_name", vnfType);
@SuppressWarnings("unchecked")
- List <VnfResource> resultList = query.list ();
+ List <VnfResource> resultList = query.list();
// See if something came back. Name is unique, so
- if (resultList.isEmpty ()) {
- LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. VNF not found", "CatalogDB", "getVnfResource", null);
+ if (resultList.isEmpty()) {
+ LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. VNF not found", "CatalogDB", "getVnfResource", null);
return null;
}
- Collections.sort (resultList, new MavenLikeVersioningComparator ());
- Collections.reverse (resultList);
+ Collections.sort(resultList, new MavenLikeVersioningComparator());
+ Collections.reverse(resultList);
- LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVnfResource", null);
- return resultList.get (0);
+ LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVnfResource", null);
+ return resultList.get(0);
}
/**
* Return the newest version of a specific VNF resource (queried by Name).
*
* @param vnfType
- * @param version
+ * @param serviceVersion
* @return VnfResource object or null if none found
*/
public VnfResource getVnfResource (String vnfType, String serviceVersion) {
- long startTime = System.currentTimeMillis ();
- LOGGER.debug ("Catalog database - get VNF resource with model_name " + vnfType + " and version=" + serviceVersion);
+ long startTime = System.currentTimeMillis();
+ LOGGER.debug("Catalog database - get VNF resource with model_name " + vnfType + " and version=" + serviceVersion);
String hql = "FROM VnfResource WHERE modelName = :vnfName and version = :serviceVersion";
- Query query = getSession ().createQuery (hql);
- query.setParameter ("vnfName", vnfType);
- query.setParameter ("serviceVersion", serviceVersion);
+ Query query = getSession().createQuery(hql);
+ query.setParameter("vnfName", vnfType);
+ query.setParameter("serviceVersion", serviceVersion);
VnfResource resource = null;
try {
- resource = (VnfResource) query.uniqueResult ();
+ resource = (VnfResource) query.uniqueResult();
} catch (org.hibernate.NonUniqueResultException nure) {
LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique row - data integrity error: vnfType='" + vnfType + "', serviceVersion='" + serviceVersion + "'");
LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for vnfType=" + vnfType + " and serviceVersion=" + serviceVersion, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for vnfType=" + vnfType);
@@ -808,22 +807,22 @@ public class CatalogDatabase implements Closeable {
* @param modelCustomizationId
* @return VnfResource object or null if none found
*/
- public VnfResource getVnfResourceByModelCustomizationId (String modelCustomizationId) {
+ public VnfResource getVnfResourceByModelCustomizationId(String modelCustomizationId) {
- long startTime = System.currentTimeMillis ();
- LOGGER.debug ("Catalog database - get VNF resource with modelCustomizationId " + modelCustomizationId);
+ long startTime = System.currentTimeMillis();
+ LOGGER.debug("Catalog database - get VNF resource with modelCustomizationId " + modelCustomizationId);
String hql = "SELECT vr "
+ "FROM VnfResource as vr JOIN vr.vnfResourceCustomizations as vrc "
+ "WHERE vrc.modelCustomizationUuid = :modelCustomizationId";
- Query query = getSession ().createQuery (hql);
- query.setParameter ("modelCustomizationId", modelCustomizationId);
+ Query query = getSession().createQuery(hql);
+ query.setParameter("modelCustomizationId", modelCustomizationId);
VnfResource resource = null;
try {
- resource = (VnfResource) query.uniqueResult ();
- } catch (org.hibernate.NonUniqueResultException nure) {
+ resource = (VnfResource) query.uniqueResult();
+ } catch(org.hibernate.NonUniqueResultException nure) {
LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique row - data integrity error: modelCustomizationUuid='" + modelCustomizationId + "'");
LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for modelCustomizationUuid=" + modelCustomizationId, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for modelCustomizationId=" + modelCustomizationId);
@@ -840,9 +839,9 @@ public class CatalogDatabase implements Closeable {
throw e;
}
if (resource == null) {
- LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "NotFound", "CatalogDB", "getVnfResourceByModelCustomizationId", null);
+ LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "NotFound", "CatalogDB", "getVnfResourceByModelCustomizationId", null);
} else {
- LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVnfResourceByModelCustomizationId", null);
+ LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVnfResourceByModelCustomizationId", null);
}
return resource;
}
@@ -855,53 +854,54 @@ public class CatalogDatabase implements Closeable {
*/
public VnfResourceCustomization getVnfResourceCustomizationByModelCustomizationName (String modelCustomizationName, String modelVersionId) {
- long startTime = System.currentTimeMillis ();
- LOGGER.debug ("Catalog database - get VNF resource Customization with modelCustomizationName " + modelCustomizationName + " serviceModelUUID " + modelVersionId);
+ long startTime = System.currentTimeMillis();
+ LOGGER.debug("Catalog database - get VNF resource Customization with modelCustomizationName " + modelCustomizationName + " serviceModelUUID " + modelVersionId);
String hql = "SELECT vrc FROM VnfResourceCustomization as vrc WHERE vrc.modelCustomizationUuid IN "
+ "(SELECT src.resourceModelCustomizationUUID FROM ServiceToResourceCustomization src "
+ "WHERE src.serviceModelUUID = :modelVersionId)"
+ "AND vrc.modelInstanceName = :modelCustomizationName";
- Query query = getSession ().createQuery (hql);
- query.setParameter ("modelCustomizationName", modelCustomizationName);
- query.setParameter ("modelVersionId", modelVersionId);
+ Query query = getSession().createQuery(hql);
+ query.setParameter("modelCustomizationName", modelCustomizationName);
+ query.setParameter("modelVersionId", modelVersionId);
@SuppressWarnings("unchecked")
- List <VnfResourceCustomization> resultList = query.list ();
+ List<VnfResourceCustomization> resultList = query.list();
- if (resultList.isEmpty ()) {
- LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. VnfResourceCustomization not found", "CatalogDB", "getVnfResourceCustomizationByModelCustomizationName", null);
+ if (resultList.isEmpty()) {
+ LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. VnfResourceCustomization not found", "CatalogDB", "getVnfResourceCustomizationByModelCustomizationName", null);
return null;
}
- Collections.sort (resultList, new MavenLikeVersioningComparator ());
- Collections.reverse (resultList);
+ Collections.sort(resultList, new MavenLikeVersioningComparator());
+ Collections.reverse(resultList);
- LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVnfResourceCustomizationByModelCustomizationName", null);
- return resultList.get (0);
+ LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVnfResourceCustomizationByModelCustomizationName", null);
+ return resultList.get(0);
}
/**
* Return the newest version of a specific VNF resource (queried by modelInvariantId).
*
- * @param version
+ * @param modelInvariantUuid model invariant ID
+ * @param modelVersion model version
* @return VnfResource object or null if none found
*/
public VnfResource getVnfResourceByModelInvariantId(String modelInvariantUuid, String modelVersion) {
- long startTime = System.currentTimeMillis ();
- LOGGER.debug ("Catalog database - get VNF resource with modelInvariantUuid " + modelInvariantUuid);
+ long startTime = System.currentTimeMillis();
+ LOGGER.debug("Catalog database - get VNF resource with modelInvariantUuid " + modelInvariantUuid);
String hql = "FROM VnfResource WHERE modelInvariantUuid = :modelInvariantUuid and version = :serviceVersion";
- Query query = getSession ().createQuery (hql);
- query.setParameter ("modelInvariantUuid", modelInvariantUuid);
- query.setParameter ("serviceVersion", modelVersion);
+ Query query = getSession().createQuery(hql);
+ query.setParameter("modelInvariantUuid", modelInvariantUuid);
+ query.setParameter("serviceVersion", modelVersion);
VnfResource resource = null;
try {
- resource = (VnfResource) query.uniqueResult ();
+ resource = (VnfResource) query.uniqueResult();
} catch (org.hibernate.NonUniqueResultException nure) {
LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique row - data integrity error: modelInvariantUuid='" + modelInvariantUuid + "', serviceVersion='" + modelVersion + "'");
LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for modelInvariantUuid=" + modelInvariantUuid + " and serviceVersion=" + modelVersion, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for modelInvariantUuid=" + modelInvariantUuid);
@@ -4880,7 +4880,7 @@ public class CatalogDatabase implements Closeable {
}
public < E > E executeQuerySingleRow(String hql, HashMap<String, String> variables, boolean retry) {
- long startTime = System.currentTimeMillis ();
+ long startTime = System.currentTimeMillis();
LOGGER.debug("Catalog database - executeQuery: " + hql + (retry ? ", retry=true" : ", retry=false"));
Query query = getSession().createQuery(hql);
@@ -4895,7 +4895,7 @@ public class CatalogDatabase implements Closeable {
E theObject = null;
try {
- theObject = (E) query.uniqueResult ();
+ theObject = (E) query.uniqueResult();
} catch (org.hibernate.NonUniqueResultException nure) {
LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique row");
LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for " + hql, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for " + hql );