diff options
Diffstat (limited to 'mso-api-handlers/mso-requests-db/src/main')
21 files changed, 1879 insertions, 28 deletions
diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/InfraRequests.java b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/InfraRequests.java index 27630c5505..5089b36573 100644 --- a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/InfraRequests.java +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/InfraRequests.java @@ -78,6 +78,10 @@ public class InfraRequests implements java.io.Serializable { private String networkName; private String networkType; private String requestorId; + private String configurationId; + private String configurationName; + private String operationalEnvId; + private String operationalEnvName; public InfraRequests() { } @@ -410,4 +414,35 @@ public class InfraRequests implements java.io.Serializable { this.requestorId = requestorId; } + public String getConfigurationId() { + return configurationId; + } + + public void setConfigurationId(String configurationId) { + this.configurationId = configurationId; + } + + public String getConfigurationName() { + return configurationName; + } + + public void setConfigurationName(String configurationName) { + this.configurationName = configurationName; + } + + public String getOperationalEnvId() { + return operationalEnvId; + } + + public void setOperationalEnvId(String operationalEnvId) { + this.operationalEnvId = operationalEnvId; + } + + public String getOperationalEnvName() { + return operationalEnvName; + } + + public void setOperationalEnvName(String operationalEnvName) { + this.operationalEnvName = operationalEnvName; + } } diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/OperationalEnvDistributionStatus.java b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/OperationalEnvDistributionStatus.java new file mode 100644 index 0000000000..2818a85020 --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/OperationalEnvDistributionStatus.java @@ -0,0 +1,106 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.requestsdb; + +import java.io.Serializable; +import java.sql.Timestamp; + +public class OperationalEnvDistributionStatus implements Serializable { + + /** + * Serialization id. + */ + private static final long serialVersionUID = 7398393659281364650L; + + private String distributionId; + private String operationalEnvId; + private String serviceModelVersionId; + private String requestId; + private String distributionIdStatus; + private String distributionIdErrorReason; + private Timestamp createTime; + private Timestamp modifyTime; + + public String getDistributionId() { + return distributionId; + } + + public void setDistributionId(String distributionId) { + this.distributionId = distributionId; + } + + public String getOperationalEnvId() { + return operationalEnvId; + } + + public void setOperationalEnvId(String operationalEnvId) { + this.operationalEnvId = operationalEnvId; + } + + public String getServiceModelVersionId() { + return serviceModelVersionId; + } + + public void setServiceModelVersionId(String serviceModelVersionId) { + this.serviceModelVersionId = serviceModelVersionId; + } + + public String getRequestId() { + return requestId; + } + + public void setRequestId(String requestId) { + this.requestId = requestId; + } + + public String getDistributionIdStatus() { + return distributionIdStatus; + } + + public void setDistributionIdStatus(String distributionIdStatus) { + this.distributionIdStatus = distributionIdStatus; + } + + public String getDistributionIdErrorReason() { + return distributionIdErrorReason; + } + + public void setDistributionIdErrorReason(String distributionIdErrorReason) { + this.distributionIdErrorReason = distributionIdErrorReason; + } + + public Timestamp getCreateTime() { + return createTime; + } + + public void setCreateTime(Timestamp createTime) { + this.createTime = createTime; + } + + public Timestamp getModifyTime() { + return modifyTime; + } + + public void setModifyTime(Timestamp modifyTime) { + this.modifyTime = modifyTime; + } + +} diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/OperationalEnvDistributionStatusDb.java b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/OperationalEnvDistributionStatusDb.java new file mode 100644 index 0000000000..ce2e1f6906 --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/OperationalEnvDistributionStatusDb.java @@ -0,0 +1,196 @@ +/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.requestsdb;
+
+
+import java.sql.Timestamp;
+
+import org.hibernate.Query;
+import org.hibernate.Session;
+import org.openecomp.mso.db.AbstractSessionFactoryManager;
+import org.openecomp.mso.logger.MessageEnum;
+import org.openecomp.mso.logger.MsoLogger;
+
+public class OperationalEnvDistributionStatusDb {
+
+ protected final AbstractSessionFactoryManager sessionFactoryRequestDB;
+
+ protected static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.GENERAL);
+
+
+ protected static final String DISTRIBUTION_ID = "distributionId";
+ protected static final String OPERATIONAL_ENV_ID = "operationalEnvId";
+ protected static final String REQUEST_ID = "requestId";
+ protected static final String SERVICE_MODEL_VERSION_ID = "serviceModelVersionId";
+ protected static final String DISTRIBUTION_ID_STATUS = "distributionIdStatus";
+ protected static final String CREATE_TIME = "startTime";
+ protected static final String MODIFY_TIME = "modifyTime";
+
+
+ public static OperationalEnvDistributionStatusDb getInstance() {
+ return new OperationalEnvDistributionStatusDb(new RequestsDbSessionFactoryManager ());
+ }
+
+ protected OperationalEnvDistributionStatusDb (AbstractSessionFactoryManager sessionFactoryRequest) {
+ sessionFactoryRequestDB = sessionFactoryRequest;
+ }
+
+
+ /**
+ * Retrieve OperationalEnvDistributionStatus from getSecgiven distributionId + * @param distributionId
+ * @return
+ */
+ public OperationalEnvDistributionStatus getOperationalEnvDistributionStatus(String distributionId) {
+ long startTime = System.currentTimeMillis ();
+ msoLogger.debug ("Retrieve Operational Environment Distribution Status with distributionId: " + distributionId);
+
+ Session session = sessionFactoryRequestDB.getSessionFactory ().openSession ();
+ OperationalEnvDistributionStatus request = null;
+ try {
+ session.beginTransaction ();
+ Query query = session.createQuery ("from OperationalEnvDistributionStatus where distributionId = :distributionId");
+ query.setParameter (DISTRIBUTION_ID, distributionId);
+ request = (OperationalEnvDistributionStatus) query.uniqueResult ();
+ } finally {
+ if (session != null && session.isOpen ()) {
+ session.close ();
+ }
+ msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
+ "Successfully", "OperationalEnvDistributionStatus", "getOperationalEnvDistributionStatus", null);
+ }
+ return request;
+ }
+
+ /**
+ * Retrieve OperationalEnvDistributionStatus from given distributionId and requestId
+ * @param distributionId
+ * @param requestId
+ * @return OperationalEnvDistributionStatus + */
+ public OperationalEnvDistributionStatus getOperationalEnvDistributionStatusPerReqId(String distributionId, String requestId) {
+ long startTime = System.currentTimeMillis ();
+ msoLogger.debug ("Retrieve Operational Environment Distribution Status with distributionId: " + distributionId + ", requestId: " + requestId);
+
+ Session session = sessionFactoryRequestDB.getSessionFactory ().openSession ();
+ OperationalEnvDistributionStatus request = null;
+ try {
+ session.beginTransaction ();
+ Query query = session.createQuery ("from OperationalEnvDistributionStatus where distributionId = :distributionId AND requestId = :requestId");
+ query.setParameter (DISTRIBUTION_ID, distributionId);
+ query.setParameter (REQUEST_ID, requestId);
+ request = (OperationalEnvDistributionStatus) query.uniqueResult ();
+ } finally {
+ if (session != null && session.isOpen ()) {
+ session.close ();
+ }
+ msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
+ "Successfully", "OperationalEnvDistributionStatus", "getOperationalEnvDistributionStatusPerReqId", null);
+ }
+ return request;
+ }
+
+ /**
+ * Update OperationalEnvDistributionStatus with distributionIdStatus for given distributionId, serviceModelVersionId, serviceModelVersionId
+ * @param asdcStatus
+ * @param distributionId
+ * @param operationalEnvId
+ * @param serviceModelVersionId
+ */
+ public int updateOperationalEnvDistributionStatus(String asdcStatus, String distributionId,
+ String operationalEnvId, String serviceModelVersionId) {
+ long startTime = System.currentTimeMillis ();
+ msoLogger.debug ("Update OperationalEnvDistributionStatus DISTRIBUTION_ID_STATUS with asdcStatus: " + asdcStatus);
+
+ Session session = sessionFactoryRequestDB.getSessionFactory ().openSession ();
+ int result = 0;
+ try {
+ session.beginTransaction ();
+ Query query = session.createQuery ("update OperationalEnvDistributionStatus set distributionIdStatus = :distributionIdStatus, modifyTime = :modifyTime where distributionId = :distributionId and "
+ + "operationalEnvId = :operationalEnvId and serviceModelVersionId = :serviceModelVersionId ");
+ query.setParameter (DISTRIBUTION_ID_STATUS, asdcStatus);
+ query.setParameter ("distributionId", distributionId);
+ query.setParameter ("operationalEnvId", operationalEnvId);
+ query.setParameter ("serviceModelVersionId", serviceModelVersionId);
+ Timestamp modifyTimeStamp = new Timestamp (System.currentTimeMillis());
+ query.setParameter ("modifyTime", modifyTimeStamp);
+ result = query.executeUpdate ();
+ session.getTransaction ().commit ();
+ } finally {
+ if (session != null && session.isOpen ()) {
+ session.close ();
+ }
+ msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "RequestDB", "updateOperationalEnvDistributionStatus", null);
+ }
+ return result;
+ }
+
+ /**
+ * Insert into OperationalEnvDistributionStatus with distributionId, operationalEnvId, serviceModelVersionId, distributionIdStatus
+ * @param distributionId
+ * @param operationalEnvId
+ * @param serviceModelVersionId
+ * @param distributionIdStatus
+ */
+ public void insertOperationalEnvDistributionStatus(String distributionId, String operationalEnvId, String serviceModelVersionId,
+ String distributionIdStatus, String requestId) {
+ long startTime = System.currentTimeMillis ();
+ Timestamp startTimeStamp = new Timestamp (System.currentTimeMillis());
+ msoLogger.debug ("Insert into OperationalEnvDistributionStatus " );
+
+ Session session = sessionFactoryRequestDB.getSessionFactory ().openSession ();
+ OperationalEnvDistributionStatus oed = new OperationalEnvDistributionStatus ();
+
+ try {
+ session.beginTransaction ();
+
+ oed.setDistributionId (distributionId);
+ oed.setOperationalEnvId (operationalEnvId);
+ oed.setServiceModelVersionId (serviceModelVersionId);
+ oed.setDistributionIdStatus (distributionIdStatus);
+ oed.setRequestId(requestId);
+ oed.setCreateTime (startTimeStamp);
+ Timestamp modifyTimeStamp = new Timestamp (System.currentTimeMillis());
+ oed.setModifyTime (modifyTimeStamp);
+
+ msoLogger.debug ("About to insert a record into OperationalEnvDistributionStatus");
+
+ session.save (oed);
+ session.getTransaction ().commit ();
+ } catch (Exception e) {
+ msoLogger.error (MessageEnum.APIH_DB_INSERT_EXC, "", "", MsoLogger.ErrorCode.SchemaError, "Exception in insertOperationalEnvDistributionStatus", e);
+ msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, e.getMessage (), "OperationalEnvDistributionStatusDB", "saveRequest", null);
+ if (session != null) {
+ session.close ();
+ }
+ // throw an Exception in the event of a DB insert failure so that the calling routine can exit
+ throw e;
+ }
+ finally {
+ if (session != null && session.isOpen ()) {
+ session.close ();
+ }
+ msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "OperationalEnvDistributionStatusDB", "insertOperationalEnvDistributionStatus", null);
+ }
+ }
+
+
+} diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/OperationalEnvServiceModelStatus.java b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/OperationalEnvServiceModelStatus.java new file mode 100644 index 0000000000..27b90ae549 --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/OperationalEnvServiceModelStatus.java @@ -0,0 +1,121 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +/** + * + */ +package org.openecomp.mso.requestsdb; + +import java.io.Serializable; +import java.sql.Timestamp; + +/** + * @author PB6115 + * + */ +public class OperationalEnvServiceModelStatus implements Serializable { + + /** + * Serialization id. + */ + private static final long serialVersionUID = 8197084996598869656L; + + private String requestId; + private String operationalEnvId; + private String serviceModelVersionId; + private String serviceModelVersionDistrStatus; + private String recoveryAction; + private int retryCount; + private String workloadContext; + private Timestamp createTime; + private Timestamp modifyTime; + + public String getRequestId() { + return requestId; + } + + public void setRequestId(String requestId) { + this.requestId = requestId; + } + + public String getOperationalEnvId() { + return operationalEnvId; + } + + public void setOperationalEnvId(String operationalEnvId) { + this.operationalEnvId = operationalEnvId; + } + + public String getServiceModelVersionId() { + return serviceModelVersionId; + } + + public void setServiceModelVersionId(String serviceModelVersionId) { + this.serviceModelVersionId = serviceModelVersionId; + } + + public String getServiceModelVersionDistrStatus() { + return serviceModelVersionDistrStatus; + } + + public void setServiceModelVersionDistrStatus(String serviceModelVersionDistrStatus) { + this.serviceModelVersionDistrStatus = serviceModelVersionDistrStatus; + } + + public String getRecoveryAction() { + return recoveryAction; + } + + public void setRecoveryAction(String recoveryAction) { + this.recoveryAction = recoveryAction; + } + + public int getRetryCount() { + return retryCount; + } + + public void setRetryCount(int retryCount) { + this.retryCount = retryCount; + } + + public String getWorkloadContext() { + return workloadContext; + } + + public void setWorkloadContext(String workloadContext) { + this.workloadContext = workloadContext; + } + + public Timestamp getCreateTime() { + return createTime; + } + public void setCreateTime(Timestamp createTime) { + this.createTime = createTime; + } + + public Timestamp getModifyTime() { + return modifyTime; + } + + public void setModifyTime(Timestamp modifyTime) { + this.modifyTime = modifyTime; + } + +} diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/OperationalEnvServiceModelStatusDb.java b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/OperationalEnvServiceModelStatusDb.java new file mode 100644 index 0000000000..1c2055ee91 --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/OperationalEnvServiceModelStatusDb.java @@ -0,0 +1,243 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.requestsdb; + +import java.sql.Timestamp; +import java.util.ArrayList; +import java.util.List; + +import org.hibernate.Query; +import org.hibernate.Session; +import org.openecomp.mso.db.AbstractSessionFactoryManager; +import org.openecomp.mso.logger.MessageEnum; +import org.openecomp.mso.logger.MsoLogger; + +public class OperationalEnvServiceModelStatusDb { + + protected final AbstractSessionFactoryManager sessionFactoryRequestDB; + + protected static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.GENERAL); + + + protected static final String REQUEST_ID = "requestId"; + protected static final String OPERATIONAL_ENV_ID = "operationalEnvId"; + protected static final String SERVICE_MODEL_VERSION_ID = "serviceModelVersionId"; + protected static final String SERVICE_MOD_VER_DISTR_STATUS = "serviceModelVersionDistrStatus"; + protected static final String RECOVERY_ACTION = "recoveryAction"; + protected static final int RETRY_COUNT_LEFT = 0; + protected static final String CREATE_TIME = "startTime"; + protected static final String MODIFY_TIME = "modifyTime"; + + + public static OperationalEnvServiceModelStatusDb getInstance() { + return new OperationalEnvServiceModelStatusDb(new RequestsDbSessionFactoryManager ()); + } + + protected OperationalEnvServiceModelStatusDb (AbstractSessionFactoryManager sessionFactoryRequest) { + sessionFactoryRequestDB = sessionFactoryRequest; + } + + + /** + * Retrieve OperationalEnvServiceModelStatus from given OperationalEnvironmentId and serviceModelVersionId + * @param operationalEnvId + * @param serviceModelVersionId + * @return + */ + public OperationalEnvServiceModelStatus getOperationalEnvServiceModelStatus(String operationalEnvId, String serviceModelVersionId) { + long startTime = System.currentTimeMillis (); + msoLogger.debug ("Retrieve OperationalEnvironmentServiceModel with operationalEnvironmentId: " + operationalEnvId + ", serviceModelVersionId: " + serviceModelVersionId); + + Session session = sessionFactoryRequestDB.getSessionFactory ().openSession (); + OperationalEnvServiceModelStatus request = null; + try { + session.beginTransaction (); + Query query = session.createQuery ("FROM OperationalEnvServiceModelStatus WHERE operationalEnvId = :operationalEnvId AND serviceModelVersionId = :serviceModelVersionId"); + query.setParameter ("operationalEnvId", operationalEnvId); + query.setParameter ("serviceModelVersionId", serviceModelVersionId); + request = (OperationalEnvServiceModelStatus) query.uniqueResult (); + } finally { + if (session != null && session.isOpen ()) { + session.close (); + } + msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, + "Successfully", "OperationalEnvServiceModelStatus", "getOperationalEnvServiceModelStatus", null); + } + return request; + } + + + /** + * Retrieve OperationalEnvServiceModelStatus from given OperationalEnvironmentId and serviceModelVersionId + * @param operationalEnvId + * @param serviceModelVersionId + * @return + */ + @SuppressWarnings("unchecked") + public List<OperationalEnvServiceModelStatus> getOperationalEnvIdStatus(String operationalEnvId, String requestId) { + long startTime = System.currentTimeMillis (); + msoLogger.debug ("Retrieve OperationalEnvironmentServiceModel with operationalEnvironmentId: " + operationalEnvId + ", requestId: " + requestId); + + Session session = sessionFactoryRequestDB.getSessionFactory ().openSession (); + List<OperationalEnvServiceModelStatus> requests = new ArrayList<OperationalEnvServiceModelStatus>(); + + try { + session.beginTransaction (); + Query query = session.createQuery ("FROM OperationalEnvServiceModelStatus WHERE operationalEnvId = :operationalEnvId AND requestId = :requestId"); + query.setParameter ("operationalEnvId", operationalEnvId); + query.setParameter ("requestId", requestId); + requests = query.list(); + } finally { + if (session != null && session.isOpen ()) { + session.close (); + } + msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, + "Successfully", "OperationalEnvServiceModelStatus", "getOperationalEnvIdStatus", null); + } + return requests; + } + + + /** + * Update OperationalEnvServiceModelStatus serviceModelVersionDistrStatus with asdcStatus and retryCount for given operationalEnvId, serviceModelVersionId + * @param operationalEnvId + * @param serviceModelVersionId + * @param asdcStatus + * @param retryCount + */ + public int updateOperationalEnvRetryCountStatus(String operationalEnvId, String serviceModelVersionId, String asdcStatus, int retryCount) { + long startTime = System.currentTimeMillis (); + msoLogger.debug ("Update OperationalEnvServiceModelStatus retryCount: " + retryCount + " and serviceModelVersionDistrStatus :" + asdcStatus); + + Session session = sessionFactoryRequestDB.getSessionFactory ().openSession (); + int result = 0; + try { + session.beginTransaction (); + Query query = session.createQuery ("update OperationalEnvServiceModelStatus set serviceModelVersionDistrStatus = :serviceModelVersionDistrStatus, retryCount = :retryCount, modifyTime = :modifyTime where " + + "operationalEnvId = :operationalEnvId and serviceModelVersionId = :serviceModelVersionId "); + query.setParameter ("retryCount", retryCount); + query.setParameter (SERVICE_MOD_VER_DISTR_STATUS, asdcStatus); + query.setParameter ("operationalEnvId", operationalEnvId); + query.setParameter ("serviceModelVersionId", serviceModelVersionId); + Timestamp modifyTimeStamp = new Timestamp (System.currentTimeMillis()); + query.setParameter ("modifyTime", modifyTimeStamp); + result = query.executeUpdate (); + session.getTransaction ().commit (); + } finally { + if (session != null && session.isOpen ()) { + session.close (); + } + msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "OperationalEnvServiceModelDB", "updateOperationalEnvRetryCountStatus", null); + } + return result; + } + + /** + * Update OperationalEnvServiceModelStatus serviceModelVersionDistrStatus with asdcStatus and retryCount for given operationalEnvId, serviceModelVersionId, requestId + * @param operationalEnvId + * @param serviceModelVersionId + * @param asdcStatus + * @param retryCount + * @param requestId + */ + public int updateOperationalEnvRetryCountStatusPerReqId(String operationalEnvId, String serviceModelVersionId, String asdcStatus, int retryCount, String requestId) { + long startTime = System.currentTimeMillis (); + msoLogger.debug ("Update OperationalEnvServiceModelStatus retryCount: " + retryCount + " and serviceModelVersionDistrStatus :" + asdcStatus); + + Session session = sessionFactoryRequestDB.getSessionFactory ().openSession (); + int result = 0; + try { + session.beginTransaction (); + Query query = session.createQuery ("update OperationalEnvServiceModelStatus set serviceModelVersionDistrStatus = :asdcStatus, retryCount = :retryCount, modifyTime = :modifyTime where " + + "operationalEnvId = :operationalEnvId and serviceModelVersionId = :serviceModelVersionId and requestId = :requestId "); + query.setParameter ("retryCount", retryCount); + query.setParameter (SERVICE_MOD_VER_DISTR_STATUS, asdcStatus); + query.setParameter ("operationalEnvId", operationalEnvId); + query.setParameter ("serviceModelVersionId", serviceModelVersionId); + query.setParameter ("requestId", requestId); + Timestamp modifyTimeStamp = new Timestamp (System.currentTimeMillis()); + query.setParameter ("modifyTime", modifyTimeStamp); + result = query.executeUpdate (); + session.getTransaction ().commit (); + } finally { + if (session != null && session.isOpen ()) { + session.close (); + } + msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "OperationalEnvServiceModelDB", "updateOperationalEnvRetryCountStatusPerReqId", null); + } + return result; + } + + + /** + * Insert into OperationalEnvServiceModelStatus with operationalEnvId, serviceModelVersionId, distributionIdStatus, recoveryAction, retryCount + * @param operationalEnvId + * @param serviceModelVersionId + * @param distributionIdStatus + * @param distributionId + * @param recoveryAction + * @param retryCount + */ + public void insertOperationalEnvServiceModelStatus(String requestId, String operationalEnvId, String serviceModelVersionId, + String distributionIdStatus, String recoveryAction, int retryCount, String workloadContext) { + long startTime = System.currentTimeMillis (); + Timestamp startTimeStamp = new Timestamp (System.currentTimeMillis()); + msoLogger.debug ("Insert into OperationalEnvServiceModelStatus " ); + + Session session = sessionFactoryRequestDB.getSessionFactory ().openSession (); + OperationalEnvServiceModelStatus oesm = new OperationalEnvServiceModelStatus (); + + try { + session.beginTransaction (); + + oesm.setRequestId (requestId); + oesm.setOperationalEnvId (operationalEnvId); + oesm.setServiceModelVersionId (serviceModelVersionId); + oesm.setServiceModelVersionDistrStatus (distributionIdStatus); + oesm.setRecoveryAction (recoveryAction); + oesm.setRetryCount (retryCount); + oesm.setWorkloadContext(workloadContext); + oesm.setCreateTime (startTimeStamp); + Timestamp modifyTimeStamp = new Timestamp (System.currentTimeMillis()); + oesm.setModifyTime (modifyTimeStamp); + + msoLogger.debug ("About to insert a record into OperationalEnvServiceModelStatus"); + + session.save (oesm); + session.getTransaction ().commit (); + } catch (Exception e) { + msoLogger.error (MessageEnum.APIH_DB_INSERT_EXC, "", "", MsoLogger.ErrorCode.SchemaError, "Exception in insertOperationalEnvServiceModelStatus", e); + msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, e.getMessage (), "OperationalEnvServiceModelStatusDB", "saveRequest", null); + if (session != null) { + session.close (); + } + // throw an Exception in the event of a DB insert failure so that the calling routine can exit + throw e; + } finally { + if (session != null && session.isOpen ()) { + session.close (); + } + msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "OperationalEnvServiceModelStatusDB", "insertOperationalEnvServiceModelStatus", null); + } + + } + +} diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/RequestsDBHelper.java b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/RequestsDBHelper.java new file mode 100644 index 0000000000..29e55b8042 --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/RequestsDBHelper.java @@ -0,0 +1,71 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.requestsdb;
+
+import org.openecomp.mso.logger.MsoLogger;
+
+public class RequestsDBHelper {
+
+ private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.APIH);
+ private String className = this.getClass().getSimpleName() +" class\'s ";
+ private String methodName = "";
+ private String classMethodMessage = "";
+
+ /**
+ * This util method is to update the InfraRequest table to Complete
+ * @param msg - string, unique message for each caller
+ * @param requestId - string
+ * @param operationalEnvironmentId - string
+ * @return void - nothing
+ * @throws Exception
+ */
+ public void updateInfraSuccessCompletion(String msg, String requestId, String operationalEnvironmentId) {
+ methodName = "updateInfraSuccessCompletion() method.";
+ classMethodMessage = className + " " + methodName;
+ msoLogger.debug("Begin of " + classMethodMessage);
+
+ RequestsDatabase requestDB = RequestsDatabase.getInstance();
+ requestDB.updateInfraFinalStatus(requestId, "COMPLETE", "SUCCESSFUL, operationalEnvironmentId - " + operationalEnvironmentId + "; Success Message: " + msg,
+ 100L, null, "APIH");
+ msoLogger.debug("End of " + classMethodMessage);
+
+ }
+
+ /**
+ * This util method is to update the InfraRequest table to Failure
+ * @param msg - string, unique message for each caller
+ * @param requestId - string
+ * @param operationalEnvironmentId - string
+ * @return void - nothing
+ * @throws Exception
+ */
+ public void updateInfraFailureCompletion(String msg, String requestId, String operationalEnvironmentId) {
+ methodName = "updateInfraFailureCompletion() method.";
+ classMethodMessage = className + " " + methodName;
+ msoLogger.debug("Begin of " + classMethodMessage);
+
+ RequestsDatabase requestDB = RequestsDatabase.getInstance();
+ requestDB.updateInfraFinalStatus(requestId, "FAILED", "FAILURE, operationalEnvironmentId - " + operationalEnvironmentId + "; Error message: " + msg,
+ 100L, null, "APIH");
+ msoLogger.debug("End of " + classMethodMessage);
+
+ }
+}
diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/RequestsDatabase.java b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/RequestsDatabase.java index d6b0b6b419..f69378ec65 100644 --- a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/RequestsDatabase.java +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/RequestsDatabase.java @@ -21,10 +21,10 @@ package org.openecomp.mso.requestsdb; -import java.util.Date; import java.sql.Timestamp; import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Date; import java.util.HashMap; import java.util.LinkedList; import java.util.List; @@ -60,13 +60,18 @@ public class RequestsDatabase { protected static final String VFMODULE_INSTANCE_NAME = "vfModuleName"; protected static final String VFMODULE_INSTANCE_ID = "vfModuleId"; protected static final String NETWORK_INSTANCE_NAME = "networkName"; + protected static final String CONFIGURATION_INSTANCE_ID = "configurationId"; + protected static final String CONFIGURATION_INSTANCE_NAME= "configurationName"; + protected static final String OPERATIONAL_ENV_ID = "operationalEnvId"; + protected static final String OPERATIONAL_ENV_NAME = "operationalEnvName"; protected static final String NETWORK_INSTANCE_ID = "networkId"; protected static final String GLOBAL_SUBSCRIBER_ID = "globalSubscriberId"; protected static final String SERVICE_NAME_VERSION_ID = "serviceNameVersionId"; protected static final String SERVICE_ID = "serviceId"; protected static final String SERVICE_VERSION = "serviceVersion"; - protected static final String REQUEST_ID = "requestId"; + protected static final String REQUESTOR_ID = "requestorId"; + protected static MockRequestsDatabase mockDB = null; public static RequestsDatabase getInstance() { @@ -237,6 +242,10 @@ public class RequestsDatabase { criteria.add (Restrictions.eq (VFMODULE_INSTANCE_NAME, instanceName)); } else if("network".equals(requestScope)){ criteria.add (Restrictions.eq (NETWORK_INSTANCE_NAME, instanceName)); + } else if(requestScope.equals("configuration")) { + criteria.add (Restrictions.eq (CONFIGURATION_INSTANCE_NAME, instanceName)); + } else if(requestScope.equals("operationalEnvironment")) { + criteria.add (Restrictions.eq (OPERATIONAL_ENV_NAME, instanceName)); } } else { @@ -260,10 +269,18 @@ public class RequestsDatabase { if("network".equals(requestScope) && instanceIdMap.get("networkInstanceId") != null){ criteria.add (Restrictions.eq (NETWORK_INSTANCE_ID, instanceIdMap.get("networkInstanceId"))); } + + if(requestScope.equals("configuration") && instanceIdMap.get("configurationInstanceId") != null){ + criteria.add (Restrictions.eq (CONFIGURATION_INSTANCE_ID, instanceIdMap.get("configurationInstanceId"))); + } + + if(requestScope.equals("operationalEnvironment") && instanceIdMap.get("operationalEnvironmentId") != null) { + criteria.add (Restrictions.eq (OPERATIONAL_ENV_ID, instanceIdMap.get("operationalEnvironmentId"))); + } } } - criteria.add (Restrictions.in ("requestStatus", new String[] { "PENDING", "IN_PROGRESS", "TIMEOUT" })); + criteria.add (Restrictions.in ("requestStatus", new String[] { "PENDING", "IN_PROGRESS", "TIMEOUT", "PENDING_MANUAL_TASK" })); Order order = Order.desc (START_TIME); @@ -305,6 +322,10 @@ public class RequestsDatabase { mapKey = "networkId"; } else if("networkInstanceName".equalsIgnoreCase(mapKey)) { mapKey = "networkName"; + } else if(mapKey.equalsIgnoreCase("configurationInstanceId")) { + mapKey = "configurationId"; + } else if(mapKey.equalsIgnoreCase("configurationInstanceName")) { + mapKey = "configurationName"; } else if("lcpCloudRegionId".equalsIgnoreCase(mapKey)) { mapKey = "aicCloudRegion"; } else if("tenantId".equalsIgnoreCase(mapKey)) { @@ -350,6 +371,54 @@ public class RequestsDatabase { return executeInfraQuery (criteria, order); } + // Added this method for Tenant Isolation project ( 1802-295491a) to query the mso_requests DB + // (infra_active_requests table) for operationalEnvId and OperationalEnvName + public List<InfraActiveRequests> getCloudOrchestrationFiltersFromInfraActive (Map<String, String> orchestrationMap) { + List <Criterion> criteria = new LinkedList <> (); + + // Add criteria on OperationalEnvironment RequestScope when requestorId is only specified in the filter + // as the same requestorId can also match on different API methods + String resourceType = orchestrationMap.get("resourceType"); + if(resourceType == null) { + criteria.add(Restrictions.eq("requestScope", "operationalEnvironment")); + } + + for (Map.Entry<String, String> entry : orchestrationMap.entrySet()) { + String mapKey = entry.getKey(); + if(mapKey.equalsIgnoreCase("requestorId")) { + mapKey = "requestorId"; + } else if(mapKey.equalsIgnoreCase("requestExecutionDate")) { + mapKey = "startTime"; + } else if(mapKey.equalsIgnoreCase("operationalEnvironmentId")) { + mapKey = "operationalEnvId"; + } else if(mapKey.equalsIgnoreCase("operationalEnvironmentName")) { + mapKey = "operationalEnvName"; + } else if(mapKey.equalsIgnoreCase("resourceType")) { + mapKey = "requestScope"; + } + + String propertyValue = entry.getValue(); + if (mapKey.equals("startTime")) { + SimpleDateFormat format = new SimpleDateFormat("MM-dd-yyyy"); + try { + Date thisDate = format.parse(propertyValue); + Timestamp minTime = new Timestamp(thisDate.getTime()); + Timestamp maxTime = new Timestamp(thisDate.getTime() + TimeUnit.DAYS.toMillis(1)); + + criteria.add(Restrictions.between(mapKey, minTime, maxTime)); + } + catch (Exception e){ + msoLogger.debug("Exception in getCloudOrchestrationFiltersFromInfraActive(): + " + e.getMessage()); + return null; + } + } else { + criteria.add(Restrictions.eq(mapKey, propertyValue)); + } + } + + Order order = Order.asc (START_TIME); + return executeInfraQuery (criteria, order); + } public List <InfraActiveRequests> getRequestListFromInfraActive (String queryAttributeName, String queryValue, @@ -412,7 +481,7 @@ public class RequestsDatabase { try { session.beginTransaction (); - Query query = session.createQuery ("from InfraActiveRequests where vnfName = :vnfName and action = :action and (requestStatus = 'PENDING' or requestStatus = 'IN_PROGRESS' or requestStatus = 'TIMEOUT') and requestType = :requestType ORDER BY startTime DESC"); + Query query = session.createQuery ("from InfraActiveRequests where vnfName = :vnfName and action = :action and (requestStatus = 'PENDING' or requestStatus = 'IN_PROGRESS' or requestStatus = 'TIMEOUT' or requestStatus = 'PENDING_MANUAL_TASK') and requestType = :requestType ORDER BY startTime DESC"); query.setParameter ("vnfName", vnfName); query.setParameter ("action", action); query.setParameter (REQUEST_TYPE, requestType); @@ -441,7 +510,7 @@ public class RequestsDatabase { try { session.beginTransaction (); - Query query = session.createQuery ("from InfraActiveRequests where vnfId = :vnfId and action = :action and (requestStatus = 'PENDING' or requestStatus = 'IN_PROGRESS' or requestStatus = 'TIMEOUT') and requestType = :requestType ORDER BY startTime DESC"); + Query query = session.createQuery ("from InfraActiveRequests where vnfId = :vnfId and action = :action and (requestStatus = 'PENDING' or requestStatus = 'IN_PROGRESS' or requestStatus = 'TIMEOUT' or requestStatus = 'PENDING_MANUAL_TASK') and requestType = :requestType ORDER BY startTime DESC"); query.setParameter ("vnfId", vnfId); query.setParameter ("action", action); query.setParameter (REQUEST_TYPE, requestType); @@ -686,8 +755,8 @@ public class RequestsDatabase { operStatus = (ResourceOperationStatus)query.uniqueResult(); } finally { - if(session != null && session.isOpen()) { - session.close(); + if (session != null && session.isOpen ()) { + session.close (); } msoLogger.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "RequestDB", "getOperationStatus", null); @@ -785,4 +854,31 @@ public class RequestsDatabase { "Successfully", "RequestDB", "updateResOperStatus", null); } } + + public InfraActiveRequests checkVnfIdStatus(String operationalEnvironmentId) { + long startTime = System.currentTimeMillis (); + msoLogger.debug ("Get Infra request from DB for OperationalEnvironmentId " + operationalEnvironmentId); + + InfraActiveRequests ar = null; + Session session = sessionFactoryRequestDB.getSessionFactory ().openSession (); + + try { + session.beginTransaction (); + Query query = session.createQuery ("FROM InfraActiveRequests WHERE operationalEnvId = :operationalEnvId AND requestStatus != 'COMPLETE' AND action = 'create' ORDER BY startTime DESC"); + query.setParameter ("operationalEnvId", operationalEnvironmentId); + + @SuppressWarnings("unchecked") + List <InfraActiveRequests> results = query.list (); + if (!results.isEmpty ()) { + ar = results.get (0); + } + } finally { + if (session != null && session.isOpen ()) { + session.close (); + } + msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "RequestDB", "checkDuplicateByVnfName", null); + } + + return ar; + } } diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/WatchdogComponentDistributionStatus.java b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/WatchdogComponentDistributionStatus.java new file mode 100644 index 0000000000..c52fe5013c --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/WatchdogComponentDistributionStatus.java @@ -0,0 +1,80 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.requestsdb; + +import java.io.Serializable; +import java.sql.Timestamp; + +public class WatchdogComponentDistributionStatus implements Serializable { + + + /** + * Serialization id. + */ + private static final long serialVersionUID = -4344508954204488669L; + + private String distributionId; + private String componentName; + private String componentDistributionStatus; + private Timestamp createTime; + private Timestamp modifyTime; + + + public String getDistributionId() { + return distributionId; + } + + public void setDistributionId(String distributionId) { + this.distributionId = distributionId; + } + + public String getComponentName() { + return componentName; + } + + public void setComponentName(String componentName) { + this.componentName = componentName; + } + + public String getComponentDistributionStatus() { + return componentDistributionStatus; + } + + public void setComponentDistributionStatus(String componentDistributionStatus) { + this.componentDistributionStatus = componentDistributionStatus; + } + + public Timestamp getCreateTime() { + return createTime; + } + public void setCreateTime(Timestamp createTime) { + this.createTime = createTime; + } + + public Timestamp getModifyTime() { + return modifyTime; + } + + public void setModifyTime(Timestamp modifyTime) { + this.modifyTime = modifyTime; + } + +} diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/WatchdogComponentDistributionStatusDb.java b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/WatchdogComponentDistributionStatusDb.java new file mode 100644 index 0000000000..10114348a0 --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/WatchdogComponentDistributionStatusDb.java @@ -0,0 +1,194 @@ +/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.requestsdb;
+
+
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.hibernate.Query;
+import org.hibernate.Session;
+import org.openecomp.mso.db.AbstractSessionFactoryManager;
+import org.openecomp.mso.requestsdb.RequestsDbSessionFactoryManager;
+import org.openecomp.mso.logger.MessageEnum;
+import org.openecomp.mso.logger.MsoLogger;
+
+public class WatchdogComponentDistributionStatusDb {
+
+ protected final AbstractSessionFactoryManager sessionFactoryRequestDB;
+
+ protected static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.GENERAL);
+
+
+ protected static final String DISTRIBUTION_ID = "distributionId";
+ protected static final String COMPONENT_NAME = "componentName";
+ protected static final String COMPONENT_DISTRIBUTION_STATUS = "componentDistributionIdStatus";
+ protected static final String CREATE_TIME = "startTime";
+ protected static final String MODIFY_TIME = "modifyTime";
+
+
+ public static WatchdogComponentDistributionStatusDb getInstance() {
+ return new WatchdogComponentDistributionStatusDb(new RequestsDbSessionFactoryManager ());
+ }
+
+ protected WatchdogComponentDistributionStatusDb (AbstractSessionFactoryManager sessionFactoryRequest) {
+ sessionFactoryRequestDB = sessionFactoryRequest;
+ }
+
+
+ /**
+ * Insert into watchdog_per_component_distribution_status.
+ *
+ * @param distributionId
+ * @param componentName
+ * @param componentDistributionStatus
+ * @return void
+ */
+ public void insertWatchdogComponentDistributionStatus(String distributionId, String componentName, String componentDistributionStatus ) {
+ long startTime = System.currentTimeMillis ();
+ Timestamp startTimeStamp = new Timestamp (System.currentTimeMillis());
+ msoLogger.debug ("Insert into WatchdogPerComponentDistributionStatus for DistributionId: " + distributionId + " ComponentName: " + componentName + " and ComponentDistributionStatus: " + componentDistributionStatus);
+
+ List<WatchdogComponentDistributionStatus> componentList = getWatchdogComponentDistributionStatus(distributionId, componentName);
+
+ if((componentList == null) || componentList.isEmpty())
+ {
+
+ Session session = sessionFactoryRequestDB.getSessionFactory ().openSession ();
+ WatchdogComponentDistributionStatus wdcds = new WatchdogComponentDistributionStatus ();
+
+ try {
+ session.beginTransaction ();
+
+ wdcds.setDistributionId (distributionId);
+ wdcds.setComponentName (componentName);
+ wdcds.setComponentDistributionStatus (componentDistributionStatus);
+ wdcds.setCreateTime (startTimeStamp);
+ Timestamp modifyTimeStamp = new Timestamp (System.currentTimeMillis());
+ wdcds.setModifyTime (modifyTimeStamp);
+
+ msoLogger.debug ("About to insert a record into WatchdogPerComponentDistributionStatus");
+
+ session.save (wdcds);
+ session.getTransaction ().commit ();
+ } catch (Exception e) {
+ msoLogger.error (MessageEnum.APIH_DB_INSERT_EXC, "", "", MsoLogger.ErrorCode.SchemaError, "Exception in insertWatchdogComponentDistributionStatus", e);
+ msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, e.getMessage (), "WatchdogComponentDistributionStatusDB", "saveRequest", null);
+ if (session != null) {
+ session.close ();
+ }
+ // throw an Exception in the event of a DB insert failure so that the calling routine can exit
+ throw e;
+ } finally {
+ if (session != null && session.isOpen ()) {
+ session.close ();
+ }
+ msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "WatchdogComponentDistributionStatusDB", "insertWatchdogComponentDistributionStatus", null);
+ }
+ }
+
+ }
+
+ /**
+ * Retrieve records from WatchdogComponentDistributionStatus.
+ *
+ * @param distributionId
+ * @return WatchdogComponentDistributionStatus
+ */
+ @SuppressWarnings("unchecked")
+ public List<WatchdogComponentDistributionStatus> getWatchdogComponentDistributionStatus(String distributionId) {
+ Session session = sessionFactoryRequestDB.getSessionFactory().openSession();
+ session.beginTransaction();
+
+ List<WatchdogComponentDistributionStatus> results = new ArrayList<WatchdogComponentDistributionStatus>();
+ msoLogger.debug("Request database - getWatchdogComponentDistributionStatus:" + distributionId);
+ try {
+ String hql = "FROM WatchdogComponentDistributionStatus WHERE distributionId = :distributionId";
+ Query query = session.createQuery(hql);
+ query.setParameter("distributionId", distributionId);
+ results = query.list();
+ } finally {
+ if (session != null && session.isOpen ()) {
+ session.close ();
+ }
+ msoLogger.debug ("getWatchdogComponentDistributionStatus - Successfully");
+ }
+ return results;
+ }
+
+ /**
+ * Retrieve records from WatchdogComponentDistributionStatus.
+ *
+ * @param distributionId
+ * @param componentName
+ * @return WatchdogComponentDistributionStatus
+ */
+ @SuppressWarnings("unchecked")
+ public List<WatchdogComponentDistributionStatus> getWatchdogComponentDistributionStatus(String distributionId, String componentName) {
+ Session session = sessionFactoryRequestDB.getSessionFactory().openSession();
+ session.beginTransaction();
+
+ List<WatchdogComponentDistributionStatus> results = new ArrayList<WatchdogComponentDistributionStatus>();
+ msoLogger.debug("Request database - getWatchdogComponentDistributionStatus:" + distributionId + " and componentName:" + componentName);
+ try {
+ String hql = "FROM WatchdogComponentDistributionStatus WHERE distributionId = :distributionId AND componentName = :componentName";
+ Query query = session.createQuery(hql);
+ query.setParameter("distributionId", distributionId);
+ query.setParameter("componentName", componentName);
+ results = query.list();
+ } finally {
+ if (session != null && session.isOpen ()) {
+ session.close ();
+ }
+ msoLogger.debug ("getWatchdogComponentDistributionStatus by ComponentName - Successfully");
+ }
+ return results;
+ }
+
+ /**
+ * Retrieve records from getWatchdogComponentNames.
+ *
+ * @param distributionId
+ * @return String
+ */
+ @SuppressWarnings("unchecked")
+ public List<String> getWatchdogComponentNames(String distributionId) {
+ Session session = sessionFactoryRequestDB.getSessionFactory().openSession();
+ session.beginTransaction();
+
+ List<String> results = new ArrayList<String>();
+ msoLogger.debug("Request database - getWatchdogComponentNames:" + distributionId);
+ try {
+ String hql = "Select componentName FROM WatchdogComponentDistributionStatus WHERE distributionId = :distributionId";
+ Query query = session.createQuery(hql);
+ query.setParameter("distributionId", distributionId);
+ results = query.list();
+ } finally {
+ if (session != null && session.isOpen ()) {
+ session.close ();
+ }
+ msoLogger.debug ("getWatchdogComponentNames - Successfully");
+ }
+ return results;
+ }
+
+}
diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/WatchdogDistributionStatus.java b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/WatchdogDistributionStatus.java new file mode 100644 index 0000000000..60f123a781 --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/WatchdogDistributionStatus.java @@ -0,0 +1,71 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.requestsdb; + +import java.io.Serializable; +import java.sql.Timestamp; + +public class WatchdogDistributionStatus implements Serializable { + + /** + * Serialization id. + */ + private static final long serialVersionUID = -4449711060885719079L; + + + private String distributionId; + private String distributionIdStatus; + private Timestamp createTime; + private Timestamp modifyTime; + + + public String getDistributionId() { + return distributionId; + } + + public void setDistributionId(String distributionId) { + this.distributionId = distributionId; + } + + public String getDistributionIdStatus() { + return distributionIdStatus; + } + + public void setDistributionIdStatus(String distributionIdStatus) { + this.distributionIdStatus = distributionIdStatus; + } + + public Timestamp getCreateTime() { + return createTime; + } + public void setCreateTime(Timestamp createTime) { + this.createTime = createTime; + } + + public Timestamp getModifyTime() { + return modifyTime; + } + + public void setModifyTime(Timestamp modifyTime) { + this.modifyTime = modifyTime; + } + +} diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/WatchdogDistributionStatusDb.java b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/WatchdogDistributionStatusDb.java new file mode 100644 index 0000000000..f1fab18df0 --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/WatchdogDistributionStatusDb.java @@ -0,0 +1,197 @@ +/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.requestsdb;
+
+
+import java.sql.Timestamp;
+
+import org.hibernate.Query;
+import org.hibernate.Session;
+import org.openecomp.mso.db.AbstractSessionFactoryManager;
+import org.openecomp.mso.logger.MessageEnum;
+import org.openecomp.mso.logger.MsoLogger;
+
+public class WatchdogDistributionStatusDb {
+
+ protected final AbstractSessionFactoryManager sessionFactoryRequestDB;
+
+ protected static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.GENERAL);
+
+
+ protected static final String DISTRIBUTION_ID = "distributionId";
+ protected static final String DISTRIBUTION_ID_STATUS = "distributionIdStatus";
+ protected static final String CREATE_TIME = "startTime";
+ protected static final String MODIFY_TIME = "modifyTime";
+
+
+ public static WatchdogDistributionStatusDb getInstance() {
+ return new WatchdogDistributionStatusDb(new RequestsDbSessionFactoryManager ());
+ }
+
+ protected WatchdogDistributionStatusDb (AbstractSessionFactoryManager sessionFactoryRequest) {
+ sessionFactoryRequestDB = sessionFactoryRequest;
+ }
+
+
+ /**
+ * Insert into WATCHDOG_DISTRIBUTIONID_STATUS.
+ *
+ * @param distributionId
+ * @return void
+ */
+ public void insertWatchdogDistributionId(String distributionId ) {
+ long startTime = System.currentTimeMillis ();
+ Timestamp startTimeStamp = new Timestamp (System.currentTimeMillis());
+ msoLogger.debug ("Insert into WatchdogDistributionStatus - DistributionId: " + distributionId);
+
+ if(getWatchdogDistributionId(distributionId) == null){
+
+ Session session = sessionFactoryRequestDB.getSessionFactory ().openSession ();
+ WatchdogDistributionStatus wds = new WatchdogDistributionStatus ();
+
+ try {
+ session.beginTransaction ();
+
+ wds.setDistributionId (distributionId);
+ wds.setCreateTime (startTimeStamp);
+ Timestamp modifyTimeStamp = new Timestamp (System.currentTimeMillis());
+ wds.setModifyTime (modifyTimeStamp);
+
+ msoLogger.debug ("About to insert a record into WatchdogDistributionStatus ");
+
+ session.save (wds);
+ session.getTransaction ().commit ();
+ } catch (Exception e) {
+ msoLogger.error (MessageEnum.APIH_DB_INSERT_EXC, "", "", MsoLogger.ErrorCode.SchemaError, "Exception in insertWatchdogDistributionId", e);
+ msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, e.getMessage (), "WatchdogDistributionStatusDB", "saveRequest", null);
+ if (session != null) {
+ session.close ();
+ }
+ // throw an Exception in the event of a DB insert failure so that the calling routine can exit
+ throw e;
+ } finally {
+ if (session != null && session.isOpen ()) {
+ session.close ();
+ }
+ msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "WatchdogDistributionStatusDB", "insertWatchdogDistributionId", null);
+ }
+
+ }
+
+ }
+
+
+ /**
+ * Update WATCHDOG_DISTRIBUTIONID_STATUS with new status for a given distributionid.
+ *
+ * @param distributionId
+ * @param distributionStatus
+ * @return void
+ */
+ public void updateWatchdogDistributionIdStatus(String distributionId, String distributionIdStatus ) {
+ long startTime = System.currentTimeMillis ();
+ msoLogger.debug ("Update WatchdogDistributionStatus status with distributionId: " + distributionId + " and distributionStatus: " + distributionIdStatus );
+
+ Session session = sessionFactoryRequestDB.getSessionFactory ().openSession ();
+
+ try {
+ session.beginTransaction ();
+ Query query = session.createQuery ("update WatchdogDistributionStatus set distributionIdStatus = :distributionIdStatus where "
+ + "distributionId = :distributionId ");
+
+ query.setParameter ("distributionId", distributionId);
+ query.setParameter ("distributionIdStatus", distributionIdStatus);
+
+ //Timestamp modifyTimeStamp = new Timestamp (System.currentTimeMillis());
+ //query.setParameter ("modifyTime", modifyTimeStamp);
+ query.executeUpdate ();
+ session.getTransaction ().commit ();
+
+ } catch (Exception e) {
+ msoLogger.error (MessageEnum.APIH_DB_INSERT_EXC, "", "", MsoLogger.ErrorCode.SchemaError, "Exception in updateWatchdogDistributionStatus", e);
+ msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, e.getMessage (), "WatchdogDistributionStatusDB", "saveRequest", null);
+ if (session != null) {
+ session.close ();
+ }
+ // throw an Exception in the event of a DB insert failure so that the calling routine can exit
+ throw e;
+ } finally {
+ if (session != null && session.isOpen ()) {
+ session.close ();
+ }
+ msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "WatchdogDistributionStatusDB", "insertWatchdogDistributionStatus", null);
+ }
+ }
+
+ /**
+ * Retrieve records from WatchdogDistributionIdStatus.
+ *
+ * @param distributionId
+ * @return WatchdogDistributionIdStatus
+ */
+ public String getWatchdogDistributionIdStatus(String distributionId) {
+ long startTime = System.currentTimeMillis ();
+ msoLogger.debug ("Retrieve records from WatchdogDistributionStatus for distributionId : " + distributionId );
+
+ Session session = sessionFactoryRequestDB.getSessionFactory ().openSession ();
+ String distributionStatus = null;
+ try {
+ session.beginTransaction ();
+ Query query = session.createQuery ("SELECT distributionIdStatus FROM WatchdogDistributionStatus WHERE distributionId = :distributionId ");
+ query.setParameter ("distributionId", distributionId);
+ distributionStatus = (String) query.uniqueResult();
+ } finally {
+ if (session != null && session.isOpen ()) {
+ session.close ();
+ }
+ msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
+ "Successfully", "WatchdogDistributionStatusDB", "getWatchdogDistributionIdStatus", null);
+ }
+ return distributionStatus;
+ }
+
+ /**
+ * Retrieve records from WatchdogDistributionId.
+ *
+ * @param distributionId
+ * @return WatchdogDistributionIdStatus
+ */
+ public String getWatchdogDistributionId(String distributionId) {
+ long startTime = System.currentTimeMillis ();
+ msoLogger.debug ("Retrieve distributionId from WatchdogDistributionStatus for distributionId : " + distributionId );
+
+ Session session = sessionFactoryRequestDB.getSessionFactory ().openSession ();
+ String existingDistributionId = null;
+ try {
+ session.beginTransaction ();
+ Query query = session.createQuery ("SELECT distributionId FROM WatchdogDistributionStatus WHERE distributionId = :distributionId ");
+ query.setParameter ("distributionId", distributionId);
+ existingDistributionId = (String) query.uniqueResult();
+ } finally {
+ if (session != null && session.isOpen ()) {
+ session.close ();
+ }
+ msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
+ "Successfully", "WatchdogDistributionStatusDB", "getWatchdogDistributionIdStatus", null);
+ }
+ return existingDistributionId;
+ }
+}
diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/WatchdogServiceModVerIdLookup.java b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/WatchdogServiceModVerIdLookup.java new file mode 100644 index 0000000000..a19b2db942 --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/WatchdogServiceModVerIdLookup.java @@ -0,0 +1,61 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.requestsdb; + +import java.io.Serializable; +import java.sql.Timestamp; + +public class WatchdogServiceModVerIdLookup implements Serializable { + + /** + * Serialization id. + */ + private static final long serialVersionUID = 7783869906430250355L; + + private String distributionId; + private String serviceModelVersionId; + private Timestamp createTime; + + + public String getDistributionId() { + return distributionId; + } + + public void setDistributionId(String distributionId) { + this.distributionId = distributionId; + } + + public String getServiceModelVersionId() { + return serviceModelVersionId; + } + + public void setServiceModelVersionId(String serviceModelVersionId) { + this.serviceModelVersionId = serviceModelVersionId; + } + + public Timestamp getCreateTime() { + return createTime; + } + public void setCreateTime(Timestamp createTime) { + this.createTime = createTime; + } + +} diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/WatchdogServiceModVerIdLookupDb.java b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/WatchdogServiceModVerIdLookupDb.java new file mode 100644 index 0000000000..f081bbf55c --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/WatchdogServiceModVerIdLookupDb.java @@ -0,0 +1,124 @@ +/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.requestsdb;
+
+
+import java.sql.Timestamp;
+
+import org.hibernate.Query;
+import org.hibernate.Session;
+import org.openecomp.mso.db.AbstractSessionFactoryManager;
+import org.openecomp.mso.logger.MessageEnum;
+import org.openecomp.mso.logger.MsoLogger;
+
+public class WatchdogServiceModVerIdLookupDb {
+
+ protected final AbstractSessionFactoryManager sessionFactoryRequestDB;
+
+ protected static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.GENERAL);
+
+ protected static final String DISTRIBUTION_ID = "distributionId";
+ protected static final String SERVICE_MODEL_VERSION_ID = "serviceModelVersionId";
+ protected static final String CREATE_TIME = "startTime";
+
+
+ public static WatchdogServiceModVerIdLookupDb getInstance() {
+ return new WatchdogServiceModVerIdLookupDb(new RequestsDbSessionFactoryManager ());
+ }
+
+ protected WatchdogServiceModVerIdLookupDb (AbstractSessionFactoryManager sessionFactoryRequest) {
+ sessionFactoryRequestDB = sessionFactoryRequest;
+ }
+
+
+ /**
+ * Insert into WATCHDOG_SERVICE_MOD_VER_ID_LOOKUP.
+ *
+ * @param distributionId
+ * @param serviceModelVersionId
+ * @return void
+ */
+ public void insertWatchdogServiceModVerIdLookup(String distributionId, String serviceModelVersionId ) {
+ long startTime = System.currentTimeMillis ();
+ Timestamp startTimeStamp = new Timestamp (System.currentTimeMillis());
+ msoLogger.debug ("Insert into WatchdogServiceModVerIdLookup for DistributionId: " + distributionId + " and ServiceModelVersionId: " + serviceModelVersionId );
+
+ if(getWatchdogServiceModVerId(distributionId) == null){
+
+ Session session = sessionFactoryRequestDB.getSessionFactory ().openSession ();
+ WatchdogServiceModVerIdLookup wdsm = new WatchdogServiceModVerIdLookup ();
+
+ try {
+ session.beginTransaction ();
+
+ wdsm.setDistributionId (distributionId);
+ wdsm.setServiceModelVersionId (serviceModelVersionId);
+ wdsm.setCreateTime (startTimeStamp);
+
+ msoLogger.debug ("About to insert a record into WatchdogServiceModVerIdLookup");
+
+ session.save (wdsm);
+ session.getTransaction ().commit ();
+ } catch (Exception e) {
+ msoLogger.error (MessageEnum.APIH_DB_INSERT_EXC, "", "", MsoLogger.ErrorCode.SchemaError, "Exception in insertWatchdogServiceModVerIdLookup", e);
+ msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, e.getMessage (), "WatchdogServiceModVerIdLookupDB", "saveRequest", null);
+ if (session != null) {
+ session.close ();
+ }
+ // throw an Exception in the event of a DB insert failure so that the calling routine can exit
+ throw e;
+ } finally {
+ if (session != null && session.isOpen ()) {
+ session.close ();
+ }
+ msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "WatchdogServiceModVerIdLookupDB", "insertWatchdogServiceModVerIdLookup", null);
+ }
+ }
+
+ }
+
+ /**
+ * Retrieve from WATCHDOG_SERVICE_MOD_VER_ID_LOOKUP.
+ *
+ * @param distributionId
+ * @return WatchdogServiceModVerIdLookup
+ */
+ public String getWatchdogServiceModVerId(String distributionId) {
+ long startTime = System.currentTimeMillis ();
+ msoLogger.debug ("Retrieve WatchdogServiceModVerIdLookup with distributionId: " + distributionId );
+
+ Session session = sessionFactoryRequestDB.getSessionFactory ().openSession ();
+ String serviceModelVersionId = null;
+ try {
+ session.beginTransaction ();
+ Query query = session.createQuery ("Select serviceModelVersionId FROM WatchdogServiceModVerIdLookup WHERE distributionId = :distributionId ");
+ query.setParameter ("distributionId", distributionId);
+ serviceModelVersionId = (String) query.uniqueResult();
+ } finally {
+ if (session != null && session.isOpen ()) {
+ session.close ();
+ }
+ msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
+ "Successfully", "WatchdogServiceModVerIdLookupDB", "getWatchdogServiceModVerId", null);
+ }
+ return serviceModelVersionId;
+ }
+}
diff --git a/mso-api-handlers/mso-requests-db/src/main/resources/InfraActiveRequests.hbm.xml b/mso-api-handlers/mso-requests-db/src/main/resources/InfraActiveRequests.hbm.xml index 8ee3dddef9..fcc6b2843e 100644 --- a/mso-api-handlers/mso-requests-db/src/main/resources/InfraActiveRequests.hbm.xml +++ b/mso-api-handlers/mso-requests-db/src/main/resources/InfraActiveRequests.hbm.xml @@ -128,7 +128,7 @@ <column name="SERVICE_INSTANCE_NAME" length="80"/> </property> <property name="requestScope" type="string"> - <column name="REQUEST_SCOPE" length="20"/> + <column name="REQUEST_SCOPE" length="45"/> </property> <property name="requestAction" type="string"> <column name="REQUEST_ACTION" length="45" not-null="true"/> @@ -145,5 +145,17 @@ <property name="requestorId" type="string"> <column name="REQUESTOR_ID" length="80"/> </property> + <property name="configurationId" type="string"> + <column name="CONFIGURATION_ID" length="45"/> + </property> + <property name="configurationName" type="string"> + <column name="CONFIGURATION_NAME" length="200"/> + </property> + <property name="operationalEnvId" type="string"> + <column name="OPERATIONAL_ENV_ID" length="45"/> + </property> + <property name="operationalEnvName" type="string"> + <column name="OPERATIONAL_ENV_NAME" length="200"/> + </property> </class> </hibernate-mapping> diff --git a/mso-api-handlers/mso-requests-db/src/main/resources/OperationStatus.hbm.xml b/mso-api-handlers/mso-requests-db/src/main/resources/OperationStatus.hbm.xml index d4eccdab33..8d80f76649 100644 --- a/mso-api-handlers/mso-requests-db/src/main/resources/OperationStatus.hbm.xml +++ b/mso-api-handlers/mso-requests-db/src/main/resources/OperationStatus.hbm.xml @@ -24,24 +24,23 @@ <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> <hibernate-mapping package="org.openecomp.mso.requestsdb"> - <class name="OperationStatus" table="OPERATION_STATUS"> - <meta attribute="class-description"> - This class describes a operation status - </meta> - <composite-id> - <key-property name="serviceId" type="string" column="SERVICE_ID"/> - <key-property name="operationId" column="OPERATION_ID" type="string" length="256"/> - </composite-id> - <property name="serviceName" column="SERVICE_NAME" type="string" length="256"/> - <property name="operation" column="OPERATION_TYPE" type="string" length="256"/> - <property name="userId" column="USER_ID" type="string" length="256"/> - <property name="result" column="RESULT" type="string" length="256"/> - <property name="operationContent" column="OPERATION_CONTENT" type="string" length="256"/> - <property name="progress" column="PROGRESS" type="string" length="256"/> - <property name="reason" column="REASON" type="string" length="256"/> - <property name="operateAt" type="timestamp"> - <column name="OPERATE_AT"/> + <class name="OperationStatus" table="OPERATION_STATUS"> + <meta attribute="class-description"> + This class describes a operation status + </meta> + <composite-id> + <key-property name="serviceId" type="string" column="SERVICE_ID"/> + <key-property name="operationId" column="OPERATION_ID" type="string" length="256"/> + </composite-id> + <property name="operation" column="OPERATION_TYPE" type="string" length="256"/> + <property name="userId" column="USER_ID" type="string" length="256"/> + <property name="result" column="RESULT" type="string" length="256"/> + <property name="operationContent" column="OPERATION_CONTENT" type="string" length="256"/> + <property name="progress" column="PROGRESS" type="string" length="256"/> + <property name="reason" column="REASON" type="string" length="256"/> + <property name="operateAt" type="timestamp" generated="insert" insert="false" update="false" not-null="true"> + <column name="OPERATE_AT" default="CURRENT_TIMESTAMP"/> </property> - <property name="finishedAt" column="FINISHED_AT" type="timestamp" /> - </class> + <property name="finishedAt" column="FINISHED_AT" type="timestamp" generated="always" insert="false" update="false"/> + </class> </hibernate-mapping> diff --git a/mso-api-handlers/mso-requests-db/src/main/resources/OperationalEnvDistributionStatus.hbm.xml b/mso-api-handlers/mso-requests-db/src/main/resources/OperationalEnvDistributionStatus.hbm.xml new file mode 100644 index 0000000000..08e60b2641 --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/main/resources/OperationalEnvDistributionStatus.hbm.xml @@ -0,0 +1,56 @@ +<?xml version="1.0"?> +<!-- + ============LICENSE_START======================================================= + ECOMP MSO + ================================================================================ + Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + ================================================================================ + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ============LICENSE_END========================================================= + --> + +<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" + "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> +<!-- Generated Jul 27, 2015 3:05:00 PM by Hibernate Tools 3.4.0.CR1 --> +<hibernate-mapping> + <class name="org.openecomp.mso.requestsdb.OperationalEnvDistributionStatus" table="ACTIVATE_OPERATIONAL_ENV_PER_DISTRIBUTIONID_STATUS"> + + <id name="distributionId" type="string"> + <column name="DISTRIBUTION_ID" length="45"/> + <generator class="assigned"/> + </id> + + <property name="operationalEnvId" type="string"> + <column name="OPERATIONAL_ENV_ID" length="45"/> + </property> + <property name="serviceModelVersionId" type="string"> + <column name="SERVICE_MODEL_VERSION_ID" length="45"/> + </property> + <property name="distributionIdStatus" type="string"> + <column name="DISTRIBUTION_ID_STATUS" length="45" /> + </property> + <property name="distributionIdErrorReason" type="string"> + <column name="DISTRIBUTION_ID_ERROR_REASON" length="250" /> + </property> + <property name="requestId" type="string"> + <column name="REQUEST_ID" length="45" /> + </property> + <property name="createTime" type="timestamp"> + <column name="CREATE_TIME"/> + </property> + <property name="modifyTime" type="timestamp"> + <column name="MODIFY_TIME"/> + </property> + + </class> +</hibernate-mapping>
\ No newline at end of file diff --git a/mso-api-handlers/mso-requests-db/src/main/resources/OperationalEnvServiceModelStatus.hbm.xml b/mso-api-handlers/mso-requests-db/src/main/resources/OperationalEnvServiceModelStatus.hbm.xml new file mode 100644 index 0000000000..99a6232e0e --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/main/resources/OperationalEnvServiceModelStatus.hbm.xml @@ -0,0 +1,54 @@ +<?xml version="1.0"?> +<!-- + ============LICENSE_START======================================================= + ECOMP MSO + ================================================================================ + Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + ================================================================================ + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ============LICENSE_END========================================================= + --> + +<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" + "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> +<!-- Generated Jul 27, 2015 3:05:00 PM by Hibernate Tools 3.4.0.CR1 --> +<hibernate-mapping> + <class name="org.openecomp.mso.requestsdb.OperationalEnvServiceModelStatus" table="ACTIVATE_OPERATIONAL_ENV_SERVICE_MODEL_DISTRIBUTION_STATUS"> + + <composite-id> + <key-property name="operationalEnvId" column="OPERATIONAL_ENV_ID" type="string" length="45" /> + <key-property name="serviceModelVersionId" column="SERVICE_MODEL_VERSION_ID" type="string" length="45"/> + <key-property name="requestId" column="REQUEST_ID" type="string" length="45"/> + </composite-id> + + <property name="serviceModelVersionDistrStatus" type="string"> + <column name="SERVICE_MOD_VER_FINAL_DISTR_STATUS" length="45"/> + </property> + <property name="recoveryAction" type="string"> + <column name="RECOVERY_ACTION" length="30" /> + </property> + <property name="retryCount" type="integer"> + <column name="RETRY_COUNT_LEFT"/> + </property> + <property name="workloadContext" type="string"> + <column name="WORKLOAD_CONTEXT" length="80" /> + </property> + <property name="createTime" type="timestamp"> + <column name="CREATE_TIME"/> + </property> + <property name="modifyTime" type="timestamp"> + <column name="MODIFY_TIME"/> + </property> + + </class> +</hibernate-mapping>
\ No newline at end of file diff --git a/mso-api-handlers/mso-requests-db/src/main/resources/WatchdogComponentDistributionStatus.hbm.xml b/mso-api-handlers/mso-requests-db/src/main/resources/WatchdogComponentDistributionStatus.hbm.xml new file mode 100644 index 0000000000..ea66153157 --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/main/resources/WatchdogComponentDistributionStatus.hbm.xml @@ -0,0 +1,46 @@ +<?xml version="1.0"?> +<!-- + ============LICENSE_START======================================================= + ECOMP MSO + ================================================================================ + Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + ================================================================================ + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ============LICENSE_END========================================================= + --> + +<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" + "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> +<!-- Generated Jul 27, 2015 3:05:00 PM by Hibernate Tools 3.4.0.CR1 --> +<hibernate-mapping> + <class name="org.openecomp.mso.requestsdb.WatchdogComponentDistributionStatus" table="WATCHDOG_PER_COMPONENT_DISTRIBUTION_STATUS"> + + <composite-id> + <key-property name="distributionId" column="DISTRIBUTION_ID" type="string" length="45" /> + <key-property name="componentName" column="COMPONENT_NAME" type="string" length="45"/> + </composite-id> + + <property name="componentDistributionStatus" type="string"> + <column name="COMPONENT_DISTRIBUTION_STATUS" length="45" /> + </property> + + <property name="createTime" type="timestamp"> + <column name="CREATE_TIME"/> + </property> + + <property name="modifyTime" type="timestamp"> + <column name="MODIFY_TIME"/> + </property> + + </class> +</hibernate-mapping>
\ No newline at end of file diff --git a/mso-api-handlers/mso-requests-db/src/main/resources/WatchdogDistributionStatus.hbm.xml b/mso-api-handlers/mso-requests-db/src/main/resources/WatchdogDistributionStatus.hbm.xml new file mode 100644 index 0000000000..2da3071c71 --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/main/resources/WatchdogDistributionStatus.hbm.xml @@ -0,0 +1,46 @@ +<?xml version="1.0"?> +<!-- + ============LICENSE_START======================================================= + ECOMP MSO + ================================================================================ + Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + ================================================================================ + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ============LICENSE_END========================================================= + --> + +<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" + "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> +<!-- Generated Jul 27, 2015 3:05:00 PM by Hibernate Tools 3.4.0.CR1 --> +<hibernate-mapping> + <class name="org.openecomp.mso.requestsdb.WatchdogDistributionStatus" table="WATCHDOG_DISTRIBUTIONID_STATUS"> + + <id name="distributionId" type="string"> + <column name="DISTRIBUTION_ID" length="45"/> + <generator class="assigned"/> + </id> + + <property name="distributionIdStatus" type="string"> + <column name="DISTRIBUTION_ID_STATUS" length="45" /> + </property> + + <property name="createTime" type="timestamp"> + <column name="CREATE_TIME"/> + </property> + + <property name="modifyTime" type="timestamp"> + <column name="MODIFY_TIME"/> + </property> + + </class> +</hibernate-mapping>
\ No newline at end of file diff --git a/mso-api-handlers/mso-requests-db/src/main/resources/WatchdogServiceModVerIdLookup.hbm.xml b/mso-api-handlers/mso-requests-db/src/main/resources/WatchdogServiceModVerIdLookup.hbm.xml new file mode 100644 index 0000000000..b6b1d9bf58 --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/main/resources/WatchdogServiceModVerIdLookup.hbm.xml @@ -0,0 +1,38 @@ +<?xml version="1.0"?> +<!-- + ============LICENSE_START======================================================= + ECOMP MSO + ================================================================================ + Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + ================================================================================ + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ============LICENSE_END========================================================= + --> + +<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" + "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> +<!-- Generated Jul 27, 2015 3:05:00 PM by Hibernate Tools 3.4.0.CR1 --> +<hibernate-mapping> + <class name="org.openecomp.mso.requestsdb.WatchdogServiceModVerIdLookup" table="WATCHDOG_SERVICE_MOD_VER_ID_LOOKUP"> + + <composite-id> + <key-property name="distributionId" column="DISTRIBUTION_ID" type="string" length="45" /> + <key-property name="serviceModelVersionId" column="SERVICE_MODEL_VERSION_ID" type="string" length="45"/> + </composite-id> + + <property name="createTime" type="timestamp"> + <column name="CREATE_TIME"/> + </property> + + </class> +</hibernate-mapping>
\ No newline at end of file diff --git a/mso-api-handlers/mso-requests-db/src/main/resources/hibernate-requests-core-mysql.cfg.xml b/mso-api-handlers/mso-requests-db/src/main/resources/hibernate-requests-core-mysql.cfg.xml index edf8333016..1305dfb97b 100644 --- a/mso-api-handlers/mso-requests-db/src/main/resources/hibernate-requests-core-mysql.cfg.xml +++ b/mso-api-handlers/mso-requests-db/src/main/resources/hibernate-requests-core-mysql.cfg.xml @@ -32,8 +32,13 @@ <!-- <property name="hibernate.hbm2ddl.auto">create</property> --> <mapping resource="InfraActiveRequests.hbm.xml"></mapping> - <mapping resource="SiteStatus.hbm.xml"></mapping> + <mapping resource="OperationalEnvServiceModelStatus.hbm.xml"></mapping> + <mapping resource="OperationalEnvDistributionStatus.hbm.xml"></mapping> <mapping resource="OperationStatus.hbm.xml"></mapping> <mapping resource="ResourceOperationStatus.hbm.xml"></mapping> + <mapping resource="SiteStatus.hbm.xml"></mapping> + <mapping resource="WatchdogDistributionStatus.hbm.xml"></mapping> + <mapping resource="WatchdogComponentDistributionStatus.hbm.xml"></mapping> + <mapping resource="WatchdogServiceModVerIdLookup.hbm.xml"></mapping> </session-factory> </hibernate-configuration> |