diff options
author | Benjamin, Max (mb388a) <mb388a@us.att.com> | 2018-07-30 15:56:09 -0400 |
---|---|---|
committer | Benjamin, Max (mb388a) <mb388a@us.att.com> | 2018-07-31 11:09:25 -0400 |
commit | 5a6a6de6f1a26a1897e4917a0df613e25a24eb70 (patch) | |
tree | 59a968f27b4b603aacc9d5e7b51fb598aeec5321 /mso-api-handlers/mso-requests-db/src/main/java/org/onap | |
parent | b6dc38501f3b746426b42d9de4cc883d894149e8 (diff) |
Containerization feature of SO
Change-Id: I95381232eeefcd247a66a5cec370a8ce1c288e18
Issue-ID: SO-670
Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'mso-api-handlers/mso-requests-db/src/main/java/org/onap')
32 files changed, 3694 insertions, 0 deletions
diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/ArchivedInfraRequests.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/ArchivedInfraRequests.java new file mode 100644 index 0000000000..b66e027a35 --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/ArchivedInfraRequests.java @@ -0,0 +1,91 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 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.onap.so.db.request.beans; + +import java.util.Objects; + +import javax.persistence.Entity; +import javax.persistence.Table; + +import org.apache.commons.lang3.builder.ToStringBuilder; + +@Entity +@Table(name = "archived_infra_requests") +public class ArchivedInfraRequests extends InfraRequests { + + private static final long serialVersionUID = 7132783898142451603L; + + public ArchivedInfraRequests() { + } + + public ArchivedInfraRequests(String requestId, String action) { + setRequestId(requestId); + setAction(action); + } + + public ArchivedInfraRequests(String requestId) { + setRequestId(requestId); + } + + @Override + public boolean equals(final Object other) { + if (this == other) { + return true; + } + if (!(other instanceof ArchivedInfraRequests)) { + return false; + } + ArchivedInfraRequests castOther = (ArchivedInfraRequests) other; + return Objects.equals(getRequestId(), castOther.getRequestId()); + } + + @Override + public int hashCode() { + return Objects.hash(getRequestId()); + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("requestId", getRequestId()) + .append("clientRequestId", getClientRequestId()).append("action", getAction()) + .append("requestStatus", getRequestStatus()).append("statusMessage", getStatusMessage()) + .append("progress", getProgress()).append("startTime", getStartTime()).append("endTime", getEndTime()) + .append("source", getSource()).append("vnfId", getVnfId()).append("vnfName", getVnfName()) + .append("vnfType", getVnfType()).append("serviceType", getServiceType()) + .append("aicNodeClli", getAicNodeClli()).append("tenantId", getTenantId()) + .append("provStatus", getProvStatus()).append("vnfParams", getVnfParams()) + .append("vnfOutputs", getVnfOutputs()).append("requestBody", getRequestBody()) + .append("responseBody", getResponseBody()).append("lastModifiedBy", getLastModifiedBy()) + .append("modifyTime", getModifyTime()).append("requestType", getRequestType()) + .append("volumeGroupId", getVolumeGroupId()).append("volumeGroupName", getVolumeGroupName()) + .append("vfModuleId", getVfModuleId()).append("vfModuleName", getVfModuleName()) + .append("vfModuleModelName", getVfModuleModelName()).append("aaiServiceId", getAaiServiceId()) + .append("aicCloudRegion", getAicCloudRegion()).append("callBackUrl", getCallBackUrl()) + .append("correlator", getCorrelator()).append("serviceInstanceId", getServiceInstanceId()) + .append("serviceInstanceName", getServiceInstanceName()).append("requestScope", getRequestScope()) + .append("requestAction", getRequestAction()).append("networkId", getNetworkId()) + .append("networkName", getNetworkName()).append("networkType", getNetworkType()) + .append("requestorId", getRequestorId()).append("configurationId", getConfigurationId()) + .append("configurationName", getConfigurationName()).append("operationalEnvId", getOperationalEnvId()) + .append("operationalEnvName", getOperationalEnvName()).toString(); + } + +} diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraActiveRequests.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraActiveRequests.java new file mode 100644 index 0000000000..84ff458698 --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraActiveRequests.java @@ -0,0 +1,93 @@ +/*- + * ============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.onap.so.db.request.beans; + +import java.util.Objects; + +import javax.persistence.Entity; +import javax.persistence.Table; + +import org.apache.commons.lang3.builder.ToStringBuilder; + +/** + * InfraActiveRequests generated by hbm2java + */ +@Entity +@Table(name = "infra_active_requests") +public class InfraActiveRequests extends InfraRequests { + + private static final long serialVersionUID = -6818265918910035170L; + + public InfraActiveRequests() { + } + + public InfraActiveRequests(String requestId, String action) { + setRequestId(requestId); + setAction(action); + } + + public InfraActiveRequests(String requestId) { + setRequestId(requestId); + } + + @Override + public boolean equals(final Object other) { + if (this == other) { + return true; + } + if (!(other instanceof InfraActiveRequests)) { + return false; + } + InfraActiveRequests castOther = (InfraActiveRequests) other; + return Objects.equals(getRequestId(), castOther.getRequestId()); + } + + @Override + public int hashCode() { + return Objects.hash(getRequestId()); + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("requestId", getRequestId()) + .append("clientRequestId", getClientRequestId()).append("action", getAction()) + .append("requestStatus", getRequestStatus()).append("statusMessage", getStatusMessage()) + .append("progress", getProgress()).append("startTime", getStartTime()).append("endTime", getEndTime()) + .append("source", getSource()).append("vnfId", getVnfId()).append("vnfName", getVnfName()) + .append("vnfType", getVnfType()).append("serviceType", getServiceType()) + .append("aicNodeClli", getAicNodeClli()).append("tenantId", getTenantId()) + .append("provStatus", getProvStatus()).append("vnfParams", getVnfParams()) + .append("vnfOutputs", getVnfOutputs()).append("requestBody", getRequestBody()) + .append("responseBody", getResponseBody()).append("lastModifiedBy", getLastModifiedBy()) + .append("modifyTime", getModifyTime()).append("requestType", getRequestType()) + .append("volumeGroupId", getVolumeGroupId()).append("volumeGroupName", getVolumeGroupName()) + .append("vfModuleId", getVfModuleId()).append("vfModuleName", getVfModuleName()) + .append("vfModuleModelName", getVfModuleModelName()).append("aaiServiceId", getAaiServiceId()) + .append("aicCloudRegion", getAicCloudRegion()).append("callBackUrl", getCallBackUrl()) + .append("correlator", getCorrelator()).append("serviceInstanceId", getServiceInstanceId()) + .append("serviceInstanceName", getServiceInstanceName()).append("requestScope", getRequestScope()) + .append("requestAction", getRequestAction()).append("networkId", getNetworkId()) + .append("networkName", getNetworkName()).append("networkType", getNetworkType()) + .append("requestorId", getRequestorId()).append("configurationId", getConfigurationId()) + .append("configurationName", getConfigurationName()).append("operationalEnvId", getOperationalEnvId()) + .append("operationalEnvName", getOperationalEnvName()).toString(); + } +} diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraRequests.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraRequests.java new file mode 100644 index 0000000000..48a6cf3ff0 --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraRequests.java @@ -0,0 +1,556 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 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.onap.so.db.request.beans; + +import java.net.URI; +import java.sql.Timestamp; +import java.util.Date; +import java.util.Objects; + +import javax.persistence.Column; +import javax.persistence.Id; +import javax.persistence.MappedSuperclass; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.onap.so.requestsdb.adapter.TimestampXMLAdapter; + +import uk.co.blackpepper.bowman.annotation.ResourceId; + +@MappedSuperclass +public abstract class InfraRequests implements java.io.Serializable { + + private static final long serialVersionUID = -5497583682393936143L; + private static final String UNKNOWN = "unknown"; + + + @Id + @Column(name = "REQUEST_ID", length=45) + private String requestId; + @Column(name = "CLIENT_REQUEST_ID", length=45, unique=true) + private String clientRequestId; + @Column(name = "ACTION", length=45) + private String action; + @Column(name = "REQUEST_STATUS", length=20) + private String requestStatus; + @Column(name = "STATUS_MESSAGE", length=2000) + private String statusMessage; + @Column(name = "PROGRESS", precision=11) + private Long progress; + + @Column(name = "START_TIME") + private Timestamp startTime; + @Column(name = "END_TIME") + private Timestamp endTime; + @Column(name = "SOURCE", length=45) + private String source; + @Column(name = "VNF_ID", length=45) + private String vnfId; + @Column(name = "VNF_NAME", length=80) + private String vnfName; + @Column(name = "VNF_TYPE", length=200) + private String vnfType; + @Column(name = "SERVICE_TYPE", length=45) + private String serviceType; + @Column(name = "AIC_NODE_CLLI", length=11) + private String aicNodeClli; + @Column(name = "TENANT_ID", length=45) + private String tenantId; + @Column(name = "PROV_STATUS", length=20) + private String provStatus; + @Column(name = "VNF_PARAMS") + private String vnfParams; + @Column(name = "VNF_OUTPUTS") + private String vnfOutputs; + @Column(name = "REQUEST_BODY") + private String requestBody; + @Column(name = "RESPONSE_BODY") + private String responseBody; + @Column(name = "LAST_MODIFIED_BY", length=50) + private String lastModifiedBy; + @Column(name = "MODIFY_TIME") + @Temporal(TemporalType.TIMESTAMP) + private Date modifyTime; + @Column(name = "REQUEST_TYPE", length=20) + private String requestType; + @Column(name = "VOLUME_GROUP_ID", length=45) + private String volumeGroupId; + @Column(name = "VOLUME_GROUP_NAME", length=45) + private String volumeGroupName; + @Column(name = "VF_MODULE_ID", length=45) + private String vfModuleId; + @Column(name = "VF_MODULE_NAME", length=200) + private String vfModuleName; + @Column(name = "VF_MODULE_MODEL_NAME", length=200) + private String vfModuleModelName; + @Column(name = "AAI_SERVICE_ID", length=50) + private String aaiServiceId; + @Column(name = "AIC_CLOUD_REGION", length=11) + private String aicCloudRegion; + @Column(name = "CALLBACK_URL", length=200) + private String callBackUrl; + @Column(name = "CORRELATOR", length=80) + private String correlator; + @Column(name = "SERVICE_INSTANCE_ID", length=45) + private String serviceInstanceId; + @Column(name = "SERVICE_INSTANCE_NAME", length=80) + private String serviceInstanceName; + @Column(name = "REQUEST_SCOPE", length=45) + private String requestScope; + @Column(name = "REQUEST_ACTION", length=45) + private String requestAction; + @Column(name = "NETWORK_ID", length=45) + private String networkId; + @Column(name = "NETWORK_NAME", length=80) + private String networkName; + @Column(name = "NETWORK_TYPE", length=80) + private String networkType; + @Column(name = "REQUESTOR_ID", length=80) + private String requestorId; + @Column(name = "CONFIGURATION_ID", length=45) + private String configurationId; + @Column(name = "CONFIGURATION_NAME", length=200) + private String configurationName; + @Column(name = "OPERATIONAL_ENV_ID", length=45) + private String operationalEnvId; + @Column(name = "OPERATIONAL_ENV_NAME", length=200) + private String operationalEnvName; + + @ResourceId + public URI getRequestURI() { + return URI.create(this.requestId); + } + + public String getRequestId() { + return this.requestId; + } + + public void setRequestId(String requestId) { + this.requestId = requestId; + } + + public String getClientRequestId() { + return clientRequestId; + } + + public void setClientRequestId(String clientRequestId) { + this.clientRequestId = clientRequestId; + } + + public String getAction() { + return this.action; + } + + public void setAction(String action) { + this.action = action; + } + + public String getRequestStatus() { + return this.requestStatus; + } + + public void setRequestStatus(String requestStatus) { + this.requestStatus = requestStatus; + } + + public String getStatusMessage() { + return this.statusMessage; + } + + public void setStatusMessage(String statusMessage) { + this.statusMessage = statusMessage; + } + + public Long getProgress() { + return this.progress; + } + + public void setProgress(Long progress) { + this.progress = progress; + } + + @XmlJavaTypeAdapter(TimestampXMLAdapter.class) + public Timestamp getStartTime() { + return this.startTime; + } + + public void setStartTime(Timestamp startTime) { + this.startTime = startTime; + } + + @XmlJavaTypeAdapter(TimestampXMLAdapter.class) + public Timestamp getEndTime() { + return this.endTime; + } + + public void setEndTime(Timestamp endTime) { + this.endTime = endTime; + } + + public String getSource() { + return this.source; + } + + public void setSource(String source) { + this.source = source; + } + + public String getVnfId() { + return this.vnfId; + } + + public void setVnfId(String vnfId) { + this.vnfId = vnfId; + } + + public String getVnfName() { + return this.vnfName; + } + + public void setVnfName(String vnfName) { + this.vnfName = vnfName; + } + + public String getVnfType() { + return this.vnfType; + } + + public void setVnfType(String vnfType) { + this.vnfType = vnfType; + } + + public String getServiceType() { + return this.serviceType; + } + + public void setServiceType(String serviceType) { + this.serviceType = serviceType; + } + + public String getAicNodeClli() { + return this.aicNodeClli; + } + + public void setAicNodeClli(String aicNodeClli) { + this.aicNodeClli = aicNodeClli; + } + + public String getTenantId() { + return this.tenantId; + } + + public void setTenantId(String tenantId) { + this.tenantId = tenantId; + } + + public String getProvStatus() { + return this.provStatus; + } + + public void setProvStatus(String provStatus) { + this.provStatus = provStatus; + } + + public String getVnfParams() { + return this.vnfParams; + } + + public void setVnfParams(String vnfParams) { + this.vnfParams = vnfParams; + } + + public String getVnfOutputs() { + return this.vnfOutputs; + } + + public void setVnfOutputs(String vnfOutputs) { + this.vnfOutputs = vnfOutputs; + } + + public String getRequestBody() { + return this.requestBody; + } + + public void setRequestBody(String requestBody) { + this.requestBody = requestBody; + } + + public String getResponseBody() { + return this.responseBody; + } + + public void setResponseBody(String responseBody) { + this.responseBody = responseBody; + } + + public String getLastModifiedBy() { + return this.lastModifiedBy; + } + + public void setLastModifiedBy(String lastModifiedBy) { + this.lastModifiedBy = lastModifiedBy; + } + + public Date getModifyTime() { + return this.modifyTime; + } + + public String getRequestType() { + return this.requestType; + } + + public void setRequestType(String requestType) { + this.requestType = requestType; + } + + public String getVolumeGroupId() { + return this.volumeGroupId; + } + + public void setVolumeGroupId(String volumeGroupId) { + this.volumeGroupId = volumeGroupId; + } + + public String getVolumeGroupName() { + return this.volumeGroupName; + } + + public void setVolumeGroupName(String volumeGroupName) { + this.volumeGroupName = volumeGroupName; + } + + public String getVfModuleId() { + return this.vfModuleId; + } + + public void setVfModuleId(String vfModuleId) { + this.vfModuleId = vfModuleId; + } + + public String getVfModuleName() { + return this.vfModuleName; + } + + public void setVfModuleName(String vfModuleName) { + this.vfModuleName = vfModuleName; + } + + public String getVfModuleModelName() { + return this.vfModuleModelName; + } + + public void setVfModuleModelName(String vfModuleModelName) { + this.vfModuleModelName = vfModuleModelName; + } + + public String getAaiServiceId() { + return this.aaiServiceId; + } + + public void setAaiServiceId(String aaiServiceId) { + this.aaiServiceId = aaiServiceId; + } + + public String getAicCloudRegion() { + return this.aicCloudRegion; + } + + public void setAicCloudRegion(String aicCloudRegion) { + this.aicCloudRegion = aicCloudRegion; + } + + public String getCallBackUrl() { + return callBackUrl; + } + + public void setCallBackUrl(String callBackUrl) { + this.callBackUrl = callBackUrl; + } + + public String getCorrelator() { + return correlator; + } + + public void setCorrelator(String correlator) { + this.correlator = correlator; + } + + public String getServiceInstanceId() { + return serviceInstanceId; + } + + public void setServiceInstanceId(String serviceInstanceId) { + this.serviceInstanceId = serviceInstanceId; + } + + public String getServiceInstanceName() { + return serviceInstanceName; + } + + public void setServiceInstanceName(String serviceInstanceName) { + this.serviceInstanceName = serviceInstanceName; + } + + public String getRequestScope() { + return requestScope; + } + + public void setRequestScope(String requestScope) { + this.requestScope = requestScope; + } + + public String getRequestAction() { + return requestAction; + } + + public void setRequestAction(String requestAction) { + this.requestAction = requestAction; + } + + public String getNetworkId() { + return networkId; + } + + public void setNetworkId(String networkId) { + this.networkId = networkId; + } + + public String getNetworkName() { + return networkName; + } + + public void setNetworkName(String networkName) { + this.networkName = networkName; + } + + public String getNetworkType() { + return networkType; + } + + public void setNetworkType(String networkType) { + this.networkType = networkType; + } + + public String getRequestorId() { + return requestorId; + } + + public void setRequestorId(String requestorId) { + 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; + } + + @PrePersist + protected void onCreate() { + if(requestScope==null) + requestScope=UNKNOWN; + if(requestAction==null) + requestAction=UNKNOWN; + this.modifyTime = new Date(); + } + + @PreUpdate + protected void onUpdate() { + if(requestScope==null) + requestScope=UNKNOWN; + if(requestAction==null) + requestAction=UNKNOWN; + this.modifyTime = new Date(); + } + + @Override + public boolean equals(final Object other) { + if (this == other) { + return true; + } + if (!(other instanceof InfraRequests)) { + return false; + } + InfraRequests castOther = (InfraRequests) other; + return Objects.equals(getRequestId(), castOther.getRequestId()); + } + + @Override + public int hashCode() { + return Objects.hash(getRequestId()); + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("requestId", getRequestId()) + .append("clientRequestId", getClientRequestId()).append("action", getAction()) + .append("requestStatus", getRequestStatus()).append("statusMessage", getStatusMessage()) + .append("progress", getProgress()).append("startTime", getStartTime()).append("endTime", getEndTime()) + .append("source", getSource()).append("vnfId", getVnfId()).append("vnfName", getVnfName()) + .append("vnfType", getVnfType()).append("serviceType", getServiceType()) + .append("aicNodeClli", getAicNodeClli()).append("tenantId", getTenantId()) + .append("provStatus", getProvStatus()).append("vnfParams", getVnfParams()) + .append("vnfOutputs", getVnfOutputs()).append("requestBody", getRequestBody()) + .append("responseBody", getResponseBody()).append("lastModifiedBy", getLastModifiedBy()) + .append("modifyTime", getModifyTime()).append("requestType", getRequestType()) + .append("volumeGroupId", getVolumeGroupId()).append("volumeGroupName", getVolumeGroupName()) + .append("vfModuleId", getVfModuleId()).append("vfModuleName", getVfModuleName()) + .append("vfModuleModelName", getVfModuleModelName()).append("aaiServiceId", getAaiServiceId()) + .append("aicCloudRegion", getAicCloudRegion()).append("callBackUrl", getCallBackUrl()) + .append("correlator", getCorrelator()).append("serviceInstanceId", getServiceInstanceId()) + .append("serviceInstanceName", getServiceInstanceName()).append("requestScope", getRequestScope()) + .append("requestAction", getRequestAction()).append("networkId", getNetworkId()) + .append("networkName", getNetworkName()).append("networkType", getNetworkType()) + .append("requestorId", getRequestorId()).append("configurationId", getConfigurationId()) + .append("configurationName", getConfigurationName()).append("operationalEnvId", getOperationalEnvId()) + .append("operationalEnvName", getOperationalEnvName()).toString(); + } +} diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/OperationStatus.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/OperationStatus.java new file mode 100644 index 0000000000..dff9dd6687 --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/OperationStatus.java @@ -0,0 +1,239 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.db.request.beans; + +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.IdClass; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; +import java.util.Objects; +import org.apache.commons.lang3.builder.ToStringBuilder; + +/** + * The service operation status + * <br> + * <p> + * </p> + * + * @author + * @version ONAP Amsterdam Release 2017-08-28 + */ + +@IdClass(OperationStatusId.class) +@Entity +@Table(name = "operation_status") +public class OperationStatus implements Serializable{ + + /** + * + */ + private static final long serialVersionUID = 1L; + + @Id + @Column(name = "SERVICE_ID") + private String serviceId; + @Id + @Column(name = "OPERATION_ID", length=256) + private String operationId; + + @Column(name = "SERVICE_NAME", length=256) + private String serviceName; + + @Column(name = "OPERATION_TYPE", length=256) + private String operation; + + @Column(name = "USER_ID", length=256) + private String userId; + + @Column(name = "RESULT", length=256) + private String result; + + @Column(name = "OPERATION_CONTENT", length=256) + private String operationContent; + + @Column(name = "PROGRESS", length=256) + private String progress = "0"; + + @Column(name = "REASON", length=256) + private String reason; + + @Column(name = "OPERATE_AT", length=256, updatable=false) + @Temporal(TemporalType.TIMESTAMP) + private Date operateAt; + + @Column(name = "FINISHED_AT", length=256) + @Temporal(TemporalType.TIMESTAMP) + private Date finishedAt; + + public OperationStatus() { + + } + + public OperationStatus(String serviceId, String operationId) { + this.serviceId = serviceId; + this.operationId = operationId; + } + + + public String getServiceId() { + return serviceId; + } + + + public void setServiceId(String serviceId) { + this.serviceId = serviceId; + } + + + public String getOperationId() { + return operationId; + } + + + public void setOperationId(String operationId) { + this.operationId = operationId; + } + + + public String getOperation() { + return operation; + } + + + public void setOperation(String operation) { + this.operation = operation; + } + + + public String getServiceName() { + return serviceName; + } + + public void setServiceName(String serviceName) { + this.serviceName = serviceName; + } + + public String getUserId() { + return userId; + } + + + public void setUserId(String userId) { + this.userId = userId; + } + + + public String getResult() { + return result; + } + + + public void setResult(String result) { + this.result = result; + } + + + public String getOperationContent() { + return operationContent; + } + + + public void setOperationContent(String operationContent) { + this.operationContent = operationContent; + } + + + public String getProgress() { + return progress; + } + + + public void setProgress(String progress) { + this.progress = progress; + } + + + public String getReason() { + return reason; + } + + + public void setReason(String reason) { + this.reason = reason; + } + + + public Date getOperateAt() { + return operateAt; + } + + public Date getFinishedAt() { + return finishedAt; + } + + @PrePersist + protected void onCreate() { + this.finishedAt = this.operateAt = new Date(); + } + + @PreUpdate + protected void onUpdate() { + this.finishedAt = new Date(); + } + + @Override + public boolean equals(final Object other) { + if (this == other) { + return true; + } + if (!(other instanceof OperationStatus)) { + return false; + } + OperationStatus castOther = (OperationStatus) other; + return Objects.equals(getServiceId(), castOther.getServiceId()) + && Objects.equals(getOperationId(), castOther.getOperationId()); + } + + @Override + public int hashCode() { + return Objects.hash(getServiceId(), getOperationId()); + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("serviceId", getServiceId()).append("operationId", getOperationId()) + .append("operation", getOperation()).append("userId", getUserId()).append("result", getResult()) + .append("operationContent", getOperationContent()).append("progress", getProgress()) + .append("reason", getReason()).append("operateAt", getOperateAt()).append("finishedAt", getFinishedAt()) + .toString(); + } + + + +} diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/OperationStatusId.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/OperationStatusId.java new file mode 100644 index 0000000000..d07788e55c --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/OperationStatusId.java @@ -0,0 +1,79 @@ +/*- + * ============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.onap.so.db.request.beans; + +import java.io.Serializable; +import java.util.Objects; + +import com.openpojo.business.annotation.BusinessKey; +import org.apache.commons.lang3.builder.ToStringBuilder; + +public class OperationStatusId implements Serializable { + + private static final long serialVersionUID = 3114959241155882723L; + + @BusinessKey + private String serviceId; + @BusinessKey + private String operationId; + + public OperationStatusId() { + + } + public OperationStatusId(String serviceId, String operationId) { + this.serviceId = serviceId; + this.operationId = operationId; + } + public String getServiceId() { + return serviceId; + } + public void setServiceId(String serviceId) { + this.serviceId = serviceId; + } + public String getOperationId() { + return operationId; + } + public void setOperationId(String operationId) { + this.operationId = operationId; + } + @Override + public boolean equals(final Object other) { + if (this == other) { + return true; + } + if (!(other instanceof OperationStatusId)) { + return false; + } + OperationStatusId castOther = (OperationStatusId) other; + return Objects.equals(this.getServiceId(), castOther.getServiceId()) + && Objects.equals(this.getOperationId(), castOther.getOperationId()); + } + @Override + public int hashCode() { + return Objects.hash(this.getServiceId(), this.getOperationId()); + } + @Override + public String toString() { + return new ToStringBuilder(this).append("serviceId", getServiceId()).append("operationId", getOperationId()) + .toString(); + } + +} diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/OperationalEnvDistributionStatus.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/OperationalEnvDistributionStatus.java new file mode 100644 index 0000000000..a1e1278306 --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/OperationalEnvDistributionStatus.java @@ -0,0 +1,177 @@ +/*- + * ============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.onap.so.db.request.beans; + +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.JoinColumns; +import javax.persistence.ManyToOne; +import javax.persistence.OneToMany; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; +import java.util.Objects; + + +import org.apache.commons.lang3.builder.ToStringBuilder; + + +@Entity +@Table(name = "activate_operational_env_per_distributionid_status") +public class OperationalEnvDistributionStatus implements Serializable { + + /** + * Serialization id. + */ + private static final long serialVersionUID = 7398393659281364650L; + + @Id + @Column(name = "DISTRIBUTION_ID", length=45) + private String distributionId; + @Column(name = "OPERATIONAL_ENV_ID", length=45) + private String operationalEnvId; + @Column(name = "SERVICE_MODEL_VERSION_ID", length=45) + private String serviceModelVersionId; + @Column(name = "REQUEST_ID", length=45) + private String requestId; + @Column(name = "DISTRIBUTION_ID_STATUS", length=45) + private String distributionIdStatus; + @Column(name = "DISTRIBUTION_ID_ERROR_REASON", length=250) + private String distributionIdErrorReason; + @Column(name = "CREATE_TIME", updatable=false) + @Temporal(TemporalType.TIMESTAMP) + private Date createTime; + @Column(name = "MODIFY_TIME") + @Temporal(TemporalType.TIMESTAMP) + private Date modifyTime; + + + public OperationalEnvDistributionStatus() { + + } + + public OperationalEnvDistributionStatus(String distributionId, String operationalEnvId, String serviceModelVersionId) { + this.distributionId = distributionId; + this.operationalEnvId = operationalEnvId; + this.serviceModelVersionId = serviceModelVersionId; + } + 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 Date getCreateTime() { + return createTime; + } + + public Date getModifyTime() { + return modifyTime; + } + + @PrePersist + protected void onCreate() { + this.createTime = this.modifyTime = new Date(); + } + + @PreUpdate + protected void onUpdate() { + this.modifyTime = new Date(); + } + + @Override + public boolean equals(final Object other) { + if (this == other) { + return true; + } + if (!(other instanceof OperationalEnvDistributionStatus)) { + return false; + } + OperationalEnvDistributionStatus castOther = (OperationalEnvDistributionStatus) other; + return Objects.equals(getDistributionId(), castOther.getDistributionId()); + } + + @Override + public int hashCode() { + return Objects.hash(getDistributionId()); + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("distributionId", getDistributionId()) + .append("operationalEnvId", getOperationalEnvId()) + .append("serviceModelVersionId", getServiceModelVersionId()).append("requestId", getRequestId()) + .append("distributionIdStatus", getDistributionIdStatus()) + .append("distributionIdErrorReason", getDistributionIdErrorReason()) + .append("createTime", getCreateTime()).append("modifyTime", getModifyTime()).toString(); + } + +} diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/OperationalEnvServiceModelStatus.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/OperationalEnvServiceModelStatus.java new file mode 100644 index 0000000000..588822cce0 --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/OperationalEnvServiceModelStatus.java @@ -0,0 +1,190 @@ +/*- + * ============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.onap.so.db.request.beans; + +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.IdClass; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; +import java.util.Objects; +import org.apache.commons.lang3.builder.ToStringBuilder; + +/** + * @author PB6115 + * + */ +@IdClass(OperationalEnvServiceModelStatusId.class) +@Entity +@Table(name = "activate_operational_env_service_model_distribution_status") +public class OperationalEnvServiceModelStatus implements Serializable { + + /** + * Serialization id. + */ + private static final long serialVersionUID = 8197084996598869656L; + + @Id + @Column(name = "REQUEST_ID", length=45) + private String requestId; + @Id + @Column(name = "OPERATIONAL_ENV_ID", length=45) + private String operationalEnvId; + @Id + @Column(name = "SERVICE_MODEL_VERSION_ID", length=45) + private String serviceModelVersionId; + @Column(name = "SERVICE_MOD_VER_FINAL_DISTR_STATUS", length=45) + private String serviceModelVersionDistrStatus; + @Column(name = "RECOVERY_ACTION", length=30) + private String recoveryAction; + @Column(name = "RETRY_COUNT_LEFT") + private Integer retryCount; + @Column(name = "WORKLOAD_CONTEXT", length=80) + private String workloadContext; + @Column(name = "CREATE_TIME", updatable=false) + @Temporal(TemporalType.TIMESTAMP) + private Date createTime; + @Column(name = "MODIFY_TIME") + @Temporal(TemporalType.TIMESTAMP) + private Date modifyTime; + + public OperationalEnvServiceModelStatus() { + + } + + public OperationalEnvServiceModelStatus(String requestId, String operationalEnvId, String serviceModelVersionId) { + this.requestId = requestId; + this.operationalEnvId = operationalEnvId; + this.serviceModelVersionId = serviceModelVersionId; + } + 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 Integer getRetryCount() { + return retryCount; + } + + public void setRetryCount(Integer retryCount) { + this.retryCount = retryCount; + } + + public String getWorkloadContext() { + return workloadContext; + } + + public void setWorkloadContext(String workloadContext) { + this.workloadContext = workloadContext; + } + + public Date getCreateTime() { + return createTime; + } + + + public Date getModifyTime() { + return modifyTime; + } + + @PrePersist + protected void onCreate() { + this.createTime = this.modifyTime = new Date(); + } + + @PreUpdate + protected void onUpdate() { + this.modifyTime = new Date(); + } + + @Override + public boolean equals(final Object other) { + if (this == other) { + return true; + } + if (!(other instanceof OperationalEnvServiceModelStatus)) { + return false; + } + OperationalEnvServiceModelStatus castOther = (OperationalEnvServiceModelStatus) other; + return Objects.equals(getRequestId(), castOther.getRequestId()) + && Objects.equals(getOperationalEnvId(), castOther.getOperationalEnvId()); + } + + @Override + public int hashCode() { + return Objects.hash(getRequestId(), getOperationalEnvId()); + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("requestId", getRequestId()) + .append("operationalEnvId", getOperationalEnvId()) + .append("serviceModelVersionId", getServiceModelVersionId()) + .append("serviceModelVersionDistrStatus", getServiceModelVersionDistrStatus()) + .append("recoveryAction", getRecoveryAction()).append("retryCount", getRetryCount()) + .append("workloadContext", getWorkloadContext()).append("createTime", getCreateTime()) + .append("modifyTime", getModifyTime()).toString(); + } + + +} diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/OperationalEnvServiceModelStatusId.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/OperationalEnvServiceModelStatusId.java new file mode 100644 index 0000000000..301e24f8ec --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/OperationalEnvServiceModelStatusId.java @@ -0,0 +1,82 @@ +/*- + * ============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.onap.so.db.request.beans; + +import java.io.Serializable; +import java.util.Objects; + +import com.openpojo.business.annotation.BusinessKey; +import org.apache.commons.lang3.builder.ToStringBuilder; + +public class OperationalEnvServiceModelStatusId implements Serializable { + + private static final long serialVersionUID = 6885534735320068787L; + + @BusinessKey + private String requestId; + @BusinessKey + private String operationalEnvId; + @BusinessKey + private String serviceModelVersionId; + + 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; + } + @Override + public boolean equals(final Object other) { + if (this == other) { + return true; + } + if (!(other instanceof OperationalEnvServiceModelStatusId)) { + return false; + } + OperationalEnvServiceModelStatusId castOther = (OperationalEnvServiceModelStatusId) other; + return Objects.equals(this.getRequestId(), castOther.getRequestId()) + && Objects.equals(this.getOperationalEnvId(), castOther.getOperationalEnvId()) + && Objects.equals(this.getServiceModelVersionId(), castOther.getServiceModelVersionId()); + } + @Override + public int hashCode() { + return Objects.hash(this.getRequestId(), this.getOperationalEnvId(), this.getServiceModelVersionId()); + } + @Override + public String toString() { + return new ToStringBuilder(this).append("requestId", getRequestId()) + .append("operationalEnvId", getOperationalEnvId()) + .append("serviceModelVersionId", getServiceModelVersionId()).toString(); + } + +} diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/ResourceOperationStatus.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/ResourceOperationStatus.java new file mode 100644 index 0000000000..386daa6dbb --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/ResourceOperationStatus.java @@ -0,0 +1,223 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.db.request.beans; + +import java.io.Serializable; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.IdClass; +import javax.persistence.Table; +import java.util.Objects; +import org.apache.commons.lang3.builder.ToStringBuilder; + +/** + * The Resource operation status + * <br> + * <p> + * </p> + * + * @author + * @version ONAP Amsterdam Release 2017-08-28 + */ + +@IdClass(ResourceOperationStatusId.class) +@Entity +@Table(name = "resource_operation_status") +public class ResourceOperationStatus implements Serializable{ + + /** + * + */ + private static final long serialVersionUID = 1L; + + @Id + @Column(name = "SERVICE_ID") + private String serviceId; + @Id + @Column(name = "OPERATION_ID", length=256) + private String operationId; + @Id + @Column(name = "RESOURCE_TEMPLATE_UUID") + private String resourceTemplateUUID; + + @Column(name = "OPER_TYPE", length=256) + private String operType; + + @Column(name = "RESOURCE_INSTANCE_ID", length=256) + private String resourceInstanceID; + + @Column(name = "JOB_ID", length=256) + private String jobId; + + @Column(name = "STATUS", length=256) + private String status; + + @Column(name = "PROGRESS", length=256) + private String progress = "0"; + + @Column(name = "ERROR_CODE", length=256) + private String errorCode; + + @Column(name = "STATUS_DESCRIPOTION", length=256) + private String statusDescription; + + public ResourceOperationStatus(){ + + } + + public ResourceOperationStatus(String serviceId, String operationId, String resourceTemplateUUID) + { + this.serviceId = serviceId; + this.operationId = operationId; + this.resourceTemplateUUID = resourceTemplateUUID; + } + + public String getServiceId() { + return serviceId; + } + + + public void setServiceId(String serviceId) { + this.serviceId = serviceId; + } + + + public String getOperationId() { + return operationId; + } + + + public void setOperationId(String operationId) { + this.operationId = operationId; + } + + + public String getResourceTemplateUUID() { + return resourceTemplateUUID; + } + + + public void setResourceTemplateUUID(String resourceTemplateUUId) { + this.resourceTemplateUUID = resourceTemplateUUId; + } + + + public String getJobId() { + return jobId; + } + + + public void setJobId(String jobId) { + this.jobId = jobId; + } + + + public String getStatus() { + return status; + } + + + public void setStatus(String status) { + this.status = status; + } + + + public String getProgress() { + return progress; + } + + + public void setProgress(String progress) { + this.progress = progress; + } + + + public String getErrorCode() { + return errorCode; + } + + + public void setErrorCode(String errorCode) { + this.errorCode = errorCode; + } + + + public String getStatusDescription() { + return statusDescription; + } + + + public void setStatusDescription(String statusDescription) { + this.statusDescription = statusDescription; + } + + + + public String getResourceInstanceID() { + return resourceInstanceID; + } + + + + public void setResourceInstanceID(String resourceInstanceID) { + this.resourceInstanceID = resourceInstanceID; + } + + + public String getOperType() { + return operType; + } + + + public void setOperType(String operType) { + this.operType = operType; + } + + @Override + public boolean equals(final Object other) { + if (this == other) { + return true; + } + if (!(other instanceof ResourceOperationStatus)) { + return false; + } + ResourceOperationStatus castOther = (ResourceOperationStatus) other; + return Objects.equals(getServiceId(), castOther.getServiceId()) + && Objects.equals(getOperationId(), castOther.getOperationId()) + && Objects.equals(getResourceTemplateUUID(), castOther.getResourceTemplateUUID()); + } + + @Override + public int hashCode() { + return Objects.hash(getServiceId(), getOperationId(), getResourceTemplateUUID()); + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("serviceId", getServiceId()).append("operationId", getOperationId()) + .append("resourceTemplateUUID", getResourceTemplateUUID()).append("operType", getOperType()) + .append("resourceInstanceID", getResourceInstanceID()).append("jobId", getJobId()) + .append("status", getStatus()).append("progress", getProgress()).append("errorCode", getErrorCode()) + .append("statusDescription", getStatusDescription()).toString(); + } +} diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/ResourceOperationStatusId.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/ResourceOperationStatusId.java new file mode 100644 index 0000000000..0f3656cd31 --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/ResourceOperationStatusId.java @@ -0,0 +1,91 @@ +/*- + * ============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.onap.so.db.request.beans; + +import java.io.Serializable; +import java.util.Objects; + +import com.openpojo.business.annotation.BusinessKey; +import org.apache.commons.lang3.builder.ToStringBuilder; + +public class ResourceOperationStatusId implements Serializable { + + private static final long serialVersionUID = -7425019928845751157L; + + @BusinessKey + private String serviceId; + @BusinessKey + private String operationId; + @BusinessKey + private String resourceTemplateUUID; + + public ResourceOperationStatusId() { + + } + + public ResourceOperationStatusId(String serviceId, String operationId, String resourceTemplateUUID) { + this.serviceId = serviceId; + this.operationId = operationId; + this.resourceTemplateUUID = resourceTemplateUUID; + } + public String getServiceId() { + return serviceId; + } + public void setServiceId(String serviceId) { + this.serviceId = serviceId; + } + public String getOperationId() { + return operationId; + } + public void setOperationId(String operationId) { + this.operationId = operationId; + } + public String getResourceTemplateUUID() { + return resourceTemplateUUID; + } + public void setResourceTemplateUUID(String resourceTemplateUUID) { + this.resourceTemplateUUID = resourceTemplateUUID; + } + @Override + public boolean equals(final Object other) { + if (this == other) { + return true; + } + if (!(other instanceof ResourceOperationStatusId)) { + return false; + } + ResourceOperationStatusId castOther = (ResourceOperationStatusId) other; + return Objects.equals(this.getServiceId(), castOther.getServiceId()) + && Objects.equals(this.getOperationId(), castOther.getOperationId()) + && Objects.equals(this.getResourceTemplateUUID(), castOther.getResourceTemplateUUID()); + } + @Override + public int hashCode() { + return Objects.hash(this.getServiceId(), this.getOperationId(),this.getResourceTemplateUUID()); + } + @Override + public String toString() { + return new ToStringBuilder(this).append("serviceId", getServiceId()).append("operationId", getOperationId()) + .append("resourceTemplateUUID", getResourceTemplateUUID()).toString(); + } + + +} diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/SiteStatus.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/SiteStatus.java new file mode 100644 index 0000000000..4e83ea5911 --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/SiteStatus.java @@ -0,0 +1,105 @@ +/*- + * ============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.onap.so.db.request.beans; + + +import java.time.format.DateTimeFormatter; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.PrePersist; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +import org.onap.so.logger.MsoLogger; +import java.util.Objects; +import org.apache.commons.lang3.builder.ToStringBuilder; + +@Entity +@Table(name = "site_status") +public class SiteStatus { + + @Column(name = "STATUS") + private boolean status; + @Id + @Column(name = "SITE_NAME") + private String siteName; + @Column(name = "CREATION_TIMESTAMP", insertable = false, updatable = false) + @Temporal(TemporalType.TIMESTAMP) + private Date created; + + public SiteStatus() { + } + + public SiteStatus(String siteName) { + this.siteName = siteName; + } + + public Date getCreated() { + return created; + } + + public String getSiteName() { + return siteName; + } + + public void setSiteName(String siteName) { + this.siteName = siteName; + } + + public void setStatus(boolean status) { + this.status = status; + } + + public boolean getStatus() { + return status; + } + + @PrePersist + protected void createdAt() { + this.created = new Date(); + } + @Override + public boolean equals(final Object other) { + if (this == other) { + return true; + } + if (!(other instanceof SiteStatus)) { + return false; + } + SiteStatus castOther = (SiteStatus) other; + return Objects.equals(getSiteName(), castOther.getSiteName()); + } + + @Override + public int hashCode() { + return Objects.hash(getSiteName()); + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("status", getStatus()).append("siteName", getSiteName()) + .append("created", getCreated()).toString(); + } +} diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/Status.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/Status.java new file mode 100644 index 0000000000..f6ee5086c9 --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/Status.java @@ -0,0 +1,40 @@ +/*- + * ============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.onap.so.db.request.beans; + + +/* + * Enum for Status values returned by API Handler to Tail-F +*/ +public enum Status { + PENDING, INPROGRESS, COMPLETED, FAILED, TIMEOUT; + + public boolean isFinished () { + switch (this) { + case COMPLETED: + case FAILED: + case TIMEOUT: + return true; + default: + return false; + } + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/WatchdogComponentDistributionStatus.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/WatchdogComponentDistributionStatus.java new file mode 100644 index 0000000000..f72a7b327a --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/WatchdogComponentDistributionStatus.java @@ -0,0 +1,140 @@ +/*- + * ============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.onap.so.db.request.beans; + +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.IdClass; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; +import java.util.Objects; +import org.apache.commons.lang3.builder.ToStringBuilder; + +@IdClass(WatchdogComponentDistributionStatusId.class) +@Entity +@Table(name = "watchdog_per_component_distribution_status") +public class WatchdogComponentDistributionStatus implements Serializable { + + + /** + * Serialization id. + */ + private static final long serialVersionUID = -4344508954204488669L; + @Id + @Column(name = "DISTRIBUTION_ID", length=45) + private String distributionId; + @Id + @Column(name = "COMPONENT_NAME", length=45) + private String componentName; + @Column(name = "COMPONENT_DISTRIBUTION_STATUS", length=45) + private String componentDistributionStatus; + @Column(name = "CREATE_TIME", updatable=false) + @Temporal(TemporalType.TIMESTAMP) + private Date createTime; + @Column(name = "MODIFY_TIME") + @Temporal(TemporalType.TIMESTAMP) + private Date modifyTime; + + public WatchdogComponentDistributionStatus() { + + } + + public WatchdogComponentDistributionStatus(String distributionId, String componentName) { + this.distributionId = distributionId; + this.componentName = componentName; + } + + 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 Date getCreateTime() { + return createTime; + } + + public Date getModifyTime() { + return modifyTime; + } + + @PrePersist + protected void onCreate() { + this.createTime = this.modifyTime = new Date(); + } + + @PreUpdate + protected void onUpdate() { + this.modifyTime = new Date(); + } + + @Override + public boolean equals(final Object other) { + if (this == other) { + return true; + } + if (!(other instanceof WatchdogComponentDistributionStatus)) { + return false; + } + WatchdogComponentDistributionStatus castOther = (WatchdogComponentDistributionStatus) other; + return Objects.equals(getDistributionId(), castOther.getDistributionId()) + && Objects.equals(getComponentName(), castOther.getComponentName()); + } + + @Override + public int hashCode() { + return Objects.hash(getDistributionId(), getComponentName()); + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("distributionId", getDistributionId()) + .append("componentName", getComponentName()) + .append("componentDistributionStatus", getComponentDistributionStatus()) + .append("createTime", getCreateTime()).append("modifyTime", getModifyTime()).toString(); + } + +} diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/WatchdogComponentDistributionStatusId.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/WatchdogComponentDistributionStatusId.java new file mode 100644 index 0000000000..79e6fbaced --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/WatchdogComponentDistributionStatusId.java @@ -0,0 +1,73 @@ +/*- + * ============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.onap.so.db.request.beans; + +import java.io.Serializable; +import java.util.Objects; + +import com.openpojo.business.annotation.BusinessKey; +import org.apache.commons.lang3.builder.ToStringBuilder; + +public class WatchdogComponentDistributionStatusId implements Serializable { + + private static final long serialVersionUID = -4785382368168200031L; + + @BusinessKey + private String distributionId; + @BusinessKey + private String componentName; + + 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; + } + @Override + public boolean equals(final Object other) { + if (this == other) { + return true; + } + if (!(other instanceof WatchdogComponentDistributionStatusId)) { + return false; + } + WatchdogComponentDistributionStatusId castOther = (WatchdogComponentDistributionStatusId) other; + return Objects.equals(this.getDistributionId(), castOther.getDistributionId()) + && Objects.equals(this.getComponentName(), castOther.getComponentName()); + } + @Override + public int hashCode() { + return Objects.hash(this.getDistributionId(), this.getComponentName()); + } + @Override + public String toString() { + return new ToStringBuilder(this).append("distributionId", getDistributionId()) + .append("componentName", getComponentName()).toString(); + } + + +} diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/WatchdogDistributionStatus.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/WatchdogDistributionStatus.java new file mode 100644 index 0000000000..40c81b96e7 --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/WatchdogDistributionStatus.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.onap.so.db.request.beans; + +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; +import java.util.Objects; +import org.apache.commons.lang3.builder.ToStringBuilder; + +@Entity +@Table(name = "watchdog_distributionid_status") +public class WatchdogDistributionStatus implements Serializable { + + /** + * Serialization id. + */ + private static final long serialVersionUID = -4449711060885719079L; + + @Id + @Column(name = "DISTRIBUTION_ID", length=45) + private String distributionId; + @Column(name = "DISTRIBUTION_ID_STATUS", length=45) + private String distributionIdStatus; + @Column(name = "CREATE_TIME", updatable=false) + @Temporal(TemporalType.TIMESTAMP) + private Date createTime; + @Column(name = "MODIFY_TIME") + @Temporal(TemporalType.TIMESTAMP) + private Date modifyTime; + + public WatchdogDistributionStatus() { + + } + + public WatchdogDistributionStatus(String distributionId) { + this.distributionId = distributionId; + } + + 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 Date getCreateTime() { + return createTime; + } + + public Date getModifyTime() { + return modifyTime; + } + + @PrePersist + protected void onCreate() { + this.createTime = this.modifyTime = new Date(); + } + + @PreUpdate + protected void onUpdate() { + this.modifyTime = new Date(); + } + + @Override + public boolean equals(final Object other) { + if (this == other) { + return true; + } + if (!(other instanceof WatchdogDistributionStatus)) { + return false; + } + WatchdogDistributionStatus castOther = (WatchdogDistributionStatus) other; + return Objects.equals(getDistributionId(), castOther.getDistributionId()); + } + + @Override + public int hashCode() { + return Objects.hash(getDistributionId()); + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("distributionId", getDistributionId()) + .append("distributionIdStatus", getDistributionIdStatus()).append("createTime", getCreateTime()) + .append("modifyTime", getModifyTime()).toString(); + } + +} diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/WatchdogServiceModVerIdLookup.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/WatchdogServiceModVerIdLookup.java new file mode 100644 index 0000000000..77089cbbdc --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/WatchdogServiceModVerIdLookup.java @@ -0,0 +1,111 @@ +/*- + * ============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.onap.so.db.request.beans; + +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.IdClass; +import javax.persistence.PrePersist; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; +import java.util.Objects; +import org.apache.commons.lang3.builder.ToStringBuilder; + +@IdClass(WatchdogServiceModVerIdLookupId.class) +@Entity +@Table(name = "watchdog_service_mod_ver_id_lookup") +public class WatchdogServiceModVerIdLookup implements Serializable { + + /** + * Serialization id. + */ + private static final long serialVersionUID = 7783869906430250355L; + + @Id + @Column(name = "DISTRIBUTION_ID", length=45) + private String distributionId; + @Id + @Column(name = "SERVICE_MODEL_VERSION_ID", length=45) + private String serviceModelVersionId; + @Column(name = "CREATE_TIME", updatable=false) + @Temporal(TemporalType.TIMESTAMP) + private Date createTime; + + public WatchdogServiceModVerIdLookup() { + + } + public WatchdogServiceModVerIdLookup(String distributionId, String serviceModelVersionId) { + this.distributionId = distributionId; + this.serviceModelVersionId = serviceModelVersionId; + } + + 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 Date getCreateTime() { + return createTime; + } + + @PrePersist + protected void onCreate() { + this.createTime = new Date(); + } + @Override + public boolean equals(final Object other) { + if (this == other) { + return true; + } + if (!(other instanceof WatchdogServiceModVerIdLookup)) { + return false; + } + WatchdogServiceModVerIdLookup castOther = (WatchdogServiceModVerIdLookup) other; + return Objects.equals(getDistributionId(), castOther.getDistributionId()) + && Objects.equals(getServiceModelVersionId(), castOther.getServiceModelVersionId()); + } + @Override + public int hashCode() { + return Objects.hash(getDistributionId(), getServiceModelVersionId()); + } + @Override + public String toString() { + return new ToStringBuilder(this).append("distributionId", getDistributionId()) + .append("serviceModelVersionId", getServiceModelVersionId()).append("createTime", getCreateTime()) + .toString(); + } +} diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/WatchdogServiceModVerIdLookupId.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/WatchdogServiceModVerIdLookupId.java new file mode 100644 index 0000000000..2c0b67bac2 --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/WatchdogServiceModVerIdLookupId.java @@ -0,0 +1,74 @@ +/*- + * ============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.onap.so.db.request.beans; + +import java.io.Serializable; +import java.util.Objects; + +import com.openpojo.business.annotation.BusinessKey; +import org.apache.commons.lang3.builder.ToStringBuilder; + +public class WatchdogServiceModVerIdLookupId implements Serializable{ + + private static final long serialVersionUID = 9112709226209619993L; + + @BusinessKey + private String distributionId; + @BusinessKey + private String serviceModelVersionId; + 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; + } + @Override + public boolean equals(final Object other) { + if (this == other) { + return true; + } + if (!(other instanceof WatchdogServiceModVerIdLookupId)) { + return false; + } + WatchdogServiceModVerIdLookupId castOther = (WatchdogServiceModVerIdLookupId) other; + return Objects.equals(this.getDistributionId(), castOther.getDistributionId()) + && Objects.equals(getServiceModelVersionId(), castOther.getServiceModelVersionId()); + } + @Override + public int hashCode() { + return Objects.hash(this.getDistributionId(), this.getServiceModelVersionId()); + } + @Override + public String toString() { + return new ToStringBuilder(this).append("distributionId", getDistributionId()) + .append("serviceModelVersionId", getServiceModelVersionId()).toString(); + } + + + + +} diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/ArchivedInfraRequestsRepository.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/ArchivedInfraRequestsRepository.java new file mode 100644 index 0000000000..f3e92ed16a --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/ArchivedInfraRequestsRepository.java @@ -0,0 +1,30 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 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.onap.so.db.request.data.repository; + +import org.onap.so.db.request.beans.ArchivedInfraRequests; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface ArchivedInfraRequestsRepository extends JpaRepository<ArchivedInfraRequests, String> { + +} diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepository.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepository.java new file mode 100644 index 0000000000..cd25b122be --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepository.java @@ -0,0 +1,41 @@ +/*- + * ============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.onap.so.db.request.data.repository; + +import java.util.Date; +import java.util.List; + +import org.onap.so.db.request.beans.InfraActiveRequests; +import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; + + +@RepositoryRestResource(collectionResourceRel = "infraActiveRequests", path = "infraActiveRequests") +public interface InfraActiveRequestsRepository extends JpaRepository<InfraActiveRequests, String>, InfraActiveRequestsRepositoryCustom { + + InfraActiveRequests findOneByRequestIdOrClientRequestId(String requestId, String clientRequestId); + InfraActiveRequests findOneByRequestIdOrClientRequestIdAndRequestType(String requestId,String clientRequestId, String requestType); + InfraActiveRequests findOneByRequestId(String string); + InfraActiveRequests findOneByRequestBody(String requestBody); + List<InfraActiveRequests> findByEndTimeLessThan(Date endTime, Pageable request); + List<InfraActiveRequests> findByStartTimeLessThanAndEndTime(Date startTime, Date endTime, Pageable request); +} diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryCustom.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryCustom.java new file mode 100644 index 0000000000..ba237bfa35 --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryCustom.java @@ -0,0 +1,57 @@ +/*- + * ============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.onap.so.db.request.data.repository; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.onap.so.db.request.beans.InfraActiveRequests; +import org.springframework.stereotype.Repository; + +@Repository +public interface InfraActiveRequestsRepositoryCustom { + + public boolean healthCheck(); + + public InfraActiveRequests getRequestFromInfraActive(String requestId); + + public InfraActiveRequests checkInstanceNameDuplicate(HashMap<String, String> instanceIdMap, String instanceName, + String requestScope); + + public List<InfraActiveRequests> getOrchestrationFiltersFromInfraActive(Map<String, List<String>> orchestrationMap); + + // 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); + + public List<InfraActiveRequests> getRequestListFromInfraActive(String queryAttributeName, String queryValue, + String requestType); + + public InfraActiveRequests getRequestFromInfraActive(String requestId, String requestType); + + public InfraActiveRequests checkDuplicateByVnfName(String vnfName, String action, String requestType); + + public InfraActiveRequests checkDuplicateByVnfId(String vnfId, String action, String requestType); + + public InfraActiveRequests checkVnfIdStatus(String operationalEnvironmentId); + +} diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImpl.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImpl.java new file mode 100644 index 0000000000..3240972a58 --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImpl.java @@ -0,0 +1,566 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.db.request.data.repository; + +import java.sql.Timestamp; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; + +import javax.persistence.EntityManager; +import javax.persistence.NonUniqueResultException; +import javax.persistence.Query; +import javax.persistence.TypedQuery; +import javax.persistence.criteria.CriteriaBuilder; +import javax.persistence.criteria.CriteriaQuery; +import javax.persistence.criteria.Order; +import javax.persistence.criteria.Predicate; +import javax.persistence.criteria.Root; + +import org.onap.so.db.request.beans.InfraActiveRequests; +import org.onap.so.db.request.beans.OperationStatus; +import org.onap.so.db.request.beans.ResourceOperationStatus; +import org.onap.so.logger.MsoLogger; +import org.onap.so.requestsdb.RequestsDbConstant; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.data.domain.Example; +import org.springframework.stereotype.Repository; +import org.springframework.transaction.annotation.Transactional; + + +@Repository +@Transactional(readOnly = true) +public class InfraActiveRequestsRepositoryImpl implements InfraActiveRequestsRepositoryCustom { + + @Qualifier("requestEntityManagerFactory") + @Autowired + private EntityManager entityManager; + + protected static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.GENERAL, InfraActiveRequestsRepositoryImpl.class); + + protected static final String SOURCE = "source"; + protected static final String START_TIME = "startTime"; + protected static final String REQUEST_TYPE = "requestType"; + protected static final String SERVICE_INSTANCE_ID = "serviceInstanceId"; + protected static final String SERVICE_INSTANCE_NAME = "serviceInstanceName"; + protected static final String VNF_INSTANCE_NAME = "vnfName"; + protected static final String VNF_INSTANCE_ID = "vnfId"; + protected static final String VOLUME_GROUP_INSTANCE_NAME = "volumeGroupName"; + protected static final String VOLUME_GROUP_INSTANCE_ID = "volumeGroupId"; + 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"; + + @Autowired + private OperationStatusRepository operationStatusRepository; + + + /* (non-Javadoc) + * @see org.onap.so.requestsdb.InfraActiveRequestsRepositoryCustom#healthCheck() + */ + @Override + public boolean healthCheck () { + + Query query = entityManager.createNativeQuery(" show tables "); + + List<?> list = query.getResultList(); + + return true; + } + + private List<InfraActiveRequests> executeInfraQuery (CriteriaQuery<InfraActiveRequests> crit, List <Predicate> predicates, Order order) { + + long startTime = System.currentTimeMillis (); + msoLogger.debug ("Execute query on infra active request table"); + + List <InfraActiveRequests> results = new ArrayList<InfraActiveRequests>(); + + try { + CriteriaBuilder cb = entityManager.getCriteriaBuilder(); + crit.where(cb.and(predicates.toArray(new Predicate[0]))); + crit.orderBy(order); + results = entityManager.createQuery(crit).getResultList(); + + } finally { + msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "RequestDB", "getInfraActiveRequest", null); + } + return results; + } + + /* (non-Javadoc) + * @see org.onap.so.requestsdb.InfraActiveRequestsRepositoryCustom#getRequestFromInfraActive(java.lang.String) + */ + @Override + public InfraActiveRequests getRequestFromInfraActive (String requestId) { + long startTime = System.currentTimeMillis (); + msoLogger.debug ("Get request " + requestId + " from InfraActiveRequests DB"); + + InfraActiveRequests ar = null; + try { + Query query = entityManager.createQuery ("from InfraActiveRequests where requestId = :requestId OR clientRequestId = :requestId"); + query.setParameter (REQUEST_ID, requestId); + ar = this.getSingleResult(query); + } finally { + + msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "InfraRequestDB", "getRequestFromInfraActive", null); + } + return ar; + } + + /* (non-Javadoc) + * @see org.onap.so.requestsdb.InfraActiveRequestsRepositoryCustom#checkInstanceNameDuplicate(java.util.HashMap, java.lang.String, java.lang.String) + */ + @Override + public InfraActiveRequests checkInstanceNameDuplicate (HashMap<String,String> instanceIdMap, String instanceName, String requestScope) { + + List <Predicate> predicates = new LinkedList <> (); + CriteriaBuilder cb = entityManager.getCriteriaBuilder(); + CriteriaQuery<InfraActiveRequests> crit = cb.createQuery(InfraActiveRequests.class); + Root<InfraActiveRequests> tableRoot = crit.from(InfraActiveRequests.class); + + if(instanceName != null && !instanceName.equals("")) { + + if("service".equals(requestScope)){ + predicates.add (cb.equal(tableRoot.get(SERVICE_INSTANCE_NAME), instanceName)); + } else if("vnf".equals(requestScope)){ + predicates.add (cb.equal(tableRoot.get(VNF_INSTANCE_NAME), instanceName)); + } else if("volumeGroup".equals(requestScope)){ + predicates.add (cb.equal(tableRoot.get(VOLUME_GROUP_INSTANCE_NAME), instanceName)); + } else if("vfModule".equals(requestScope)){ + predicates.add (cb.equal(tableRoot.get(VFMODULE_INSTANCE_NAME), instanceName)); + } else if("network".equals(requestScope)){ + predicates.add (cb.equal(tableRoot.get(NETWORK_INSTANCE_NAME), instanceName)); + } else if(requestScope.equals("configuration")) { + predicates.add (cb.equal(tableRoot.get(CONFIGURATION_INSTANCE_NAME), instanceName)); + } else if(requestScope.equals("operationalEnvironment")) { + predicates.add (cb.equal(tableRoot.get(OPERATIONAL_ENV_NAME), instanceName)); + } + + } else { + if(instanceIdMap != null){ + if("service".equals(requestScope) && instanceIdMap.get("serviceInstanceId") != null){ + predicates.add (cb.equal(tableRoot.get(SERVICE_INSTANCE_ID), instanceIdMap.get("serviceInstanceId"))); + } + + if("vnf".equals(requestScope) && instanceIdMap.get("vnfInstanceId") != null){ + predicates.add (cb.equal(tableRoot.get(VNF_INSTANCE_ID), instanceIdMap.get("vnfInstanceId" ))); + } + + if("vfModule".equals(requestScope) && instanceIdMap.get("vfModuleInstanceId") != null){ + predicates.add (cb.equal(tableRoot.get(VFMODULE_INSTANCE_ID), instanceIdMap.get("vfModuleInstanceId"))); + } + + if("volumeGroup".equals(requestScope) && instanceIdMap.get("volumeGroupInstanceId") != null){ + predicates.add (cb.equal(tableRoot.get(VOLUME_GROUP_INSTANCE_ID), instanceIdMap.get("volumeGroupInstanceId"))); + } + + if("network".equals(requestScope) && instanceIdMap.get("networkInstanceId") != null){ + predicates.add (cb.equal(tableRoot.get(NETWORK_INSTANCE_ID), instanceIdMap.get("networkInstanceId"))); + } + + if(requestScope.equals("configuration") && instanceIdMap.get("configurationInstanceId") != null){ + predicates.add (cb.equal(tableRoot.get(CONFIGURATION_INSTANCE_ID), instanceIdMap.get("configurationInstanceId"))); + } + + if(requestScope.equals("operationalEnvironment") && instanceIdMap.get("operationalEnvironmentId") != null) { + predicates.add (cb.equal(tableRoot.get(OPERATIONAL_ENV_ID), instanceIdMap.get("operationalEnvironmentId"))); + } + } + } + + predicates.add (tableRoot.get("requestStatus").in(Arrays.asList("PENDING", "IN_PROGRESS", "TIMEOUT", "PENDING_MANUAL_TASK"))); + + Order order = cb.desc(tableRoot.get(START_TIME)); + + List<InfraActiveRequests> dupList = executeInfraQuery(crit, predicates, order); + + InfraActiveRequests infraActiveRequests = null; + + if(dupList != null && !dupList.isEmpty()){ + infraActiveRequests = dupList.get(0); + } + + return infraActiveRequests; + } + + /* (non-Javadoc) + * @see org.onap.so.requestsdb.InfraActiveRequestsRepositoryCustom#getOrchestrationFiltersFromInfraActive(java.util.Map) + */ + @Override + public List<InfraActiveRequests> getOrchestrationFiltersFromInfraActive (Map<String, List<String>> orchestrationMap) { + + + List <Predicate> predicates = new LinkedList <> (); + CriteriaBuilder cb = entityManager.getCriteriaBuilder(); + CriteriaQuery<InfraActiveRequests> crit = cb.createQuery(InfraActiveRequests.class); + Root<InfraActiveRequests> tableRoot = crit.from(InfraActiveRequests.class); + for (Map.Entry<String, List<String>> entry : orchestrationMap.entrySet()) + { + String mapKey = entry.getKey(); + if("serviceInstanceId".equalsIgnoreCase(mapKey)) { + mapKey = "serviceInstanceId"; + } else if("serviceInstanceName".equalsIgnoreCase(mapKey)) { + mapKey = "serviceInstanceName"; + } else if("vnfInstanceId".equalsIgnoreCase(mapKey)){ + mapKey = "vnfId"; + } else if("vnfInstanceName".equalsIgnoreCase(mapKey)) { + mapKey = "vnfName"; + } else if("vfModuleInstanceId".equalsIgnoreCase(mapKey)) { + mapKey = "vfModuleId"; + } else if("vfModuleInstanceName".equalsIgnoreCase(mapKey)) { + mapKey = "vfModuleName"; + } else if("volumeGroupInstanceId".equalsIgnoreCase(mapKey)) { + mapKey = "volumeGroupId"; + } else if("volumeGroupInstanceName".equalsIgnoreCase(mapKey)) { + mapKey = "volumeGroupName"; + } else if("networkInstanceId".equalsIgnoreCase(mapKey)) { + 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)) { + mapKey = "tenantId"; + } else if("modelType".equalsIgnoreCase(mapKey)) { + mapKey = "requestScope"; + } else if("requestorId".equalsIgnoreCase(mapKey)) { + mapKey = "requestorId"; + } else if("requestExecutionDate".equalsIgnoreCase(mapKey)) { + mapKey = "startTime"; + } + + String propertyValue = entry.getValue().get(1); + if ("startTime".equals(mapKey)) { + 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)); + + if("DOES_NOT_EQUAL".equalsIgnoreCase(entry.getValue().get(0))) { + predicates.add(cb.or(cb.lessThan(tableRoot.get(mapKey), minTime), cb.greaterThanOrEqualTo(tableRoot.get(mapKey), maxTime))); + } else { + predicates.add(cb.between(tableRoot.get(mapKey), minTime, maxTime)); + } + } + catch (Exception e){ + msoLogger.debug("Exception in getOrchestrationFiltersFromInfraActive(): + " + e.getMessage(), e); + return null; + } + } + else if("DOES_NOT_EQUAL".equalsIgnoreCase(entry.getValue().get(0))) { + predicates.add(cb.notEqual(tableRoot.get(mapKey), propertyValue)); + } else { + predicates.add(cb.equal(tableRoot.get(mapKey), propertyValue)); + } + + } + + Order order = cb.asc(tableRoot.get(START_TIME)); + + return executeInfraQuery (crit, predicates, order); + } + + // Added this method for Tenant Isolation project ( 1802-295491a) to query the mso_requests DB + // (infra_active_requests table) for operationalEnvId and OperationalEnvName + /* (non-Javadoc) + * @see org.onap.so.requestsdb.InfraActiveRequestsRepositoryCustom#getCloudOrchestrationFiltersFromInfraActive(java.util.Map) + */ + @Override + public List<InfraActiveRequests> getCloudOrchestrationFiltersFromInfraActive (Map<String, String> orchestrationMap) { + List <Predicate> predicates = new LinkedList <> (); + CriteriaBuilder cb = entityManager.getCriteriaBuilder(); + CriteriaQuery<InfraActiveRequests> crit = cb.createQuery(InfraActiveRequests.class); + Root<InfraActiveRequests> tableRoot = crit.from(InfraActiveRequests.class); + + // 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) { + predicates.add(cb.equal(tableRoot.get("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)); + + predicates.add(cb.between(tableRoot.get(mapKey), minTime, maxTime)); + } + catch (Exception e){ + msoLogger.debug("Exception in getCloudOrchestrationFiltersFromInfraActive(): + " + e.getMessage()); + return null; + } + } else { + predicates.add(cb.equal(tableRoot.get(mapKey), propertyValue)); + } + } + + Order order = cb.asc(tableRoot.get(START_TIME)); + return executeInfraQuery (crit, predicates, order); + } + + /* (non-Javadoc) + * @see org.onap.so.requestsdb.InfraActiveRequestsRepositoryCustom#getRequestListFromInfraActive(java.lang.String, java.lang.String, java.lang.String) + */ + @Override + public List <InfraActiveRequests> getRequestListFromInfraActive (String queryAttributeName, + String queryValue, + String requestType) { + msoLogger.debug ("Get list of infra requests from DB with " + queryAttributeName + " = " + queryValue); + + + try { + CriteriaBuilder cb = entityManager.getCriteriaBuilder(); + CriteriaQuery<InfraActiveRequests> crit = cb.createQuery(InfraActiveRequests.class); + Root<InfraActiveRequests> candidateRoot = crit.from(InfraActiveRequests.class); + Predicate isEqual = cb.equal(candidateRoot.get(queryAttributeName), queryValue); + Predicate equalRequestType = cb.equal(candidateRoot.get(REQUEST_TYPE), requestType); + Predicate isNull = cb.isNull(candidateRoot.get(REQUEST_TYPE)); + Predicate orClause = cb.or(equalRequestType, isNull); + Order orderDesc = cb.desc(candidateRoot.get(START_TIME)); + Order orderAsc = cb.asc(candidateRoot.get(SOURCE)); + crit.where(cb.and(isEqual, orClause)).orderBy(orderDesc, orderAsc); + + @SuppressWarnings("unchecked") + List <InfraActiveRequests> arList = entityManager.createQuery(crit).getResultList(); + if (arList != null && !arList.isEmpty ()) { + return arList; + } + } finally { + // msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "RequestDB", "getRequestListFromInfraActive", null); + } + return null; + } + + + /* (non-Javadoc) + * @see org.onap.so.requestsdb.InfraActiveRequestsRepositoryCustom#getRequestFromInfraActive(java.lang.String, java.lang.String) + */ + @Override + public InfraActiveRequests getRequestFromInfraActive (String requestId, String requestType) { + long startTime = System.currentTimeMillis (); + msoLogger.debug ("Get infra request from DB with id " + requestId); + + InfraActiveRequests ar = null; + try { + Query query = entityManager.createQuery ("from InfraActiveRequests where (requestId = :requestId OR clientRequestId = :requestId) and requestType = :requestType"); + query.setParameter (REQUEST_ID, requestId); + query.setParameter (REQUEST_TYPE, requestType); + ar = this.getSingleResult(query); + } finally { + msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "RequestDB", "getRequestFromInfraActive", null); + } + return ar; + } + + + /* (non-Javadoc) + * @see org.onap.so.requestsdb.InfraActiveRequestsRepositoryCustom#checkDuplicateByVnfName(java.lang.String, java.lang.String, java.lang.String) + */ + @Override + public InfraActiveRequests checkDuplicateByVnfName (String vnfName, String action, String requestType) { + + long startTime = System.currentTimeMillis (); + msoLogger.debug ("Get infra request from DB for VNF " + vnfName + " and action " + action + " and requestType " + requestType); + + InfraActiveRequests ar = null; + try { + Query query = entityManager.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); + @SuppressWarnings("unchecked") + List <InfraActiveRequests> results = query.getResultList(); + if (!results.isEmpty ()) { + ar = results.get (0); + } + } finally { + msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "RequestDB", "checkDuplicateByVnfName", null); + } + + return ar; + } + + /* (non-Javadoc) + * @see org.onap.so.requestsdb.InfraActiveRequestsRepositoryCustom#checkDuplicateByVnfId(java.lang.String, java.lang.String, java.lang.String) + */ + @Override + public InfraActiveRequests checkDuplicateByVnfId (String vnfId, String action, String requestType) { + + long startTime = System.currentTimeMillis (); + msoLogger.debug ("Get list of infra requests from DB for VNF " + vnfId + " and action " + action); + + InfraActiveRequests ar = null; + try { + Query query = entityManager.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); + @SuppressWarnings("unchecked") + List <InfraActiveRequests> results = query.getResultList(); + if (!results.isEmpty ()) { + ar = results.get (0); + } + } finally { + msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "RequestDB", "checkDuplicateByVnfId", null); + } + + return ar; + } + + /** + * update service operation status when a operation resource status updated + * <br> + * + * @param operStatus the resource operation status + * @since ONAP Amsterdam Release + */ + private void updateOperationStatusBasedOnResourceStatus(ResourceOperationStatus operStatus) { + long startTime = System.currentTimeMillis(); + msoLogger.debug("Request database - query Resource Operation Status with service Id:" + + operStatus.getServiceId() + ", operationId:" + operStatus.getOperationId()); + try { + // query all resources of the service + String hql = "FROM ResourceOperationStatus WHERE SERVICE_ID = :service_id and OPERATION_ID = :operation_id"; + Query query = entityManager.createQuery(hql); + query.setParameter("service_id", operStatus.getServiceId()); + query.setParameter("operation_id", operStatus.getOperationId()); + @SuppressWarnings("unchecked") + List<ResourceOperationStatus> lstResourceStatus = (List<ResourceOperationStatus>)query.getResultList(); + // count the total progress + int resourceCount = lstResourceStatus.size(); + int progress = 0; + boolean isFinished = true; + for(int i = 0; i < resourceCount; i++) { + progress = progress + Integer.valueOf(lstResourceStatus.get(i).getProgress()) / resourceCount; + if(RequestsDbConstant.Status.PROCESSING.equals(lstResourceStatus.get(i).getStatus())) { + isFinished = false; + } + } + + OperationStatus serviceOperStatus = new OperationStatus(operStatus.getServiceId(), operStatus.getOperationId()); + serviceOperStatus = operationStatusRepository.findOne(Example.of(serviceOperStatus)); + progress = progress > 100 ? 100 : progress; + serviceOperStatus.setProgress(String.valueOf(progress)); + serviceOperStatus.setOperationContent(operStatus.getStatusDescription()); + // if current resource failed. service failed. + if(RequestsDbConstant.Status.ERROR.equals(operStatus.getStatus())) { + serviceOperStatus.setResult(RequestsDbConstant.Status.ERROR); + serviceOperStatus.setReason(operStatus.getStatusDescription()); + } else if(isFinished) { + // if finished + serviceOperStatus.setResult(RequestsDbConstant.Status.FINISHED); + serviceOperStatus.setProgress(RequestsDbConstant.Progress.ONE_HUNDRED); + } + operationStatusRepository.save(serviceOperStatus); + } finally { + msoLogger.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, + "Successfully", "RequestDB", "updateResOperStatus", null); + } + } + + /* (non-Javadoc) + * @see org.onap.so.requestsdb.InfraActiveRequestsRepositoryCustom#checkVnfIdStatus(java.lang.String) + */ + @Override + public InfraActiveRequests checkVnfIdStatus(String operationalEnvironmentId) { + long startTime = System.currentTimeMillis (); + msoLogger.debug ("Get Infra request from DB for OperationalEnvironmentId " + operationalEnvironmentId); + + InfraActiveRequests ar = null; + try { + CriteriaBuilder cb = entityManager.getCriteriaBuilder(); + CriteriaQuery<InfraActiveRequests> crit = cb.createQuery(InfraActiveRequests.class); + Root<InfraActiveRequests> candidateRoot = crit.from(InfraActiveRequests.class); + Predicate operationalEnvEq = cb.equal(candidateRoot.get("operationalEnvId"), operationalEnvironmentId); + Predicate requestStatusNotEq = cb.notEqual(candidateRoot.get("requestStatus"), "COMPLETE"); + Predicate actionEq = cb.equal(candidateRoot.get("action"), "create"); + Order startTimeOrder = cb.desc(candidateRoot.get("startTime")); + crit.select(candidateRoot); + crit.where(cb.and(operationalEnvEq, requestStatusNotEq, actionEq)); + crit.orderBy(startTimeOrder); + TypedQuery<InfraActiveRequests> query = entityManager.createQuery(crit); + @SuppressWarnings("unchecked") + List <InfraActiveRequests> results = query.getResultList(); + if (!results.isEmpty ()) { + ar = results.get (0); + } + } finally { + msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "RequestDB", "checkDuplicateByVnfName", null); + } + + return ar; + } + + protected <T> T getSingleResult(Query query) { + query.setMaxResults(1); + List<T> list = query.getResultList(); + if (list == null || list.isEmpty()) { + return null; + } else if (list.size() == 1) { + return list.get(0); + } else { + throw new NonUniqueResultException(); + } + + } +} diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/OperationStatusRepository.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/OperationStatusRepository.java new file mode 100644 index 0000000000..c51e4edcea --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/OperationStatusRepository.java @@ -0,0 +1,34 @@ +/*- + * ============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.onap.so.db.request.data.repository; + +import org.onap.so.db.request.beans.OperationStatus; +import org.onap.so.db.request.beans.OperationStatusId; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface OperationStatusRepository extends JpaRepository<OperationStatus, OperationStatusId> { + + OperationStatus findOneByServiceIdAndOperationId(String serviceId, String operationId); + public OperationStatus findOneByServiceName(String serviceName); + public OperationStatus findOneByServiceId(String serviceId); +} diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/OperationalEnvDistributionStatusRepository.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/OperationalEnvDistributionStatusRepository.java new file mode 100644 index 0000000000..799e5ad147 --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/OperationalEnvDistributionStatusRepository.java @@ -0,0 +1,42 @@ +/*- + * ============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.onap.so.db.request.data.repository; + +import org.onap.so.db.request.beans.OperationalEnvDistributionStatus; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Modifying; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; +import org.springframework.stereotype.Repository; +import org.springframework.transaction.annotation.Transactional; + +@Repository +public interface OperationalEnvDistributionStatusRepository extends JpaRepository<OperationalEnvDistributionStatus, String> { + + @Modifying + @Transactional + @Query("update OperationalEnvDistributionStatus set distributionIdStatus = :distributionIdStatus where " + + "distributionId = :distributionId and operationalEnvId = :operationalEnvId and serviceModelVersionId = :serviceModelVersionId") + public int setDistributionIdStatus(@Param("distributionIdStatus") String distributionIdStatus, + @Param("distributionId") String distributionId, + @Param("operationalEnvId") String operationalEnvId, + @Param("serviceModelVersionId") String serviceModelVersionId); +} diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/OperationalEnvServiceModelStatusRepository.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/OperationalEnvServiceModelStatusRepository.java new file mode 100644 index 0000000000..ee2baedf61 --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/OperationalEnvServiceModelStatusRepository.java @@ -0,0 +1,59 @@ +/*- + * ============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.onap.so.db.request.data.repository; + +import java.util.List; + +import org.onap.so.db.request.beans.OperationalEnvServiceModelStatus; +import org.onap.so.db.request.beans.OperationalEnvServiceModelStatusId; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Modifying; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; +import org.springframework.stereotype.Repository; +import org.springframework.transaction.annotation.Transactional; + +@Repository +public interface OperationalEnvServiceModelStatusRepository extends JpaRepository<OperationalEnvServiceModelStatus, OperationalEnvServiceModelStatusId>{ + + public OperationalEnvServiceModelStatus findOneByOperationalEnvIdAndRequestId(String operationalEnvId, String requestId); + public List<OperationalEnvServiceModelStatus> findAllByOperationalEnvIdAndRequestId(String operationalEnvId, String requestId); + public OperationalEnvServiceModelStatus findOneByOperationalEnvIdAndServiceModelVersionId(String operationalEnvId, String serviceModelVersionId); + + @Modifying + @Transactional + @Query("update OperationalEnvServiceModelStatus set serviceModelVersionDistrStatus = :asdcStatus, retryCount = :retryCount where " + + "operationalEnvId = :operationalEnvId and serviceModelVersionId = :serviceModelVersionId") + public int setServiceModelVersionDistrStatusAndRetryCountFor(@Param("asdcStatus") String serviceModelVersionDistrStatus, + @Param("retryCount") int retryCount, + @Param("operationalEnvId") String operationalEnvId, + @Param("serviceModelVersionId") String serviceModelVersionId); + + @Modifying + @Transactional + @Query("update OperationalEnvServiceModelStatus set serviceModelVersionDistrStatus = :asdcStatus, retryCount = :retryCount where " + + "operationalEnvId = :operationalEnvId and serviceModelVersionId = :serviceModelVersionId and requestId = :requestId") + public int setServiceModelVersionDistrStatusAndRetryCountFor(@Param("asdcStatus") String serviceModelVersionDistrStatus, + @Param("retryCount") int retryCount, + @Param("operationalEnvId") String operationalEnvId, + @Param("serviceModelVersionId") String serviceModelVersionId, + @Param("requestId") String requestId); +} diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/ResourceOperationStatusRepository.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/ResourceOperationStatusRepository.java new file mode 100644 index 0000000000..2d77f7589e --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/ResourceOperationStatusRepository.java @@ -0,0 +1,34 @@ +/*- + * ============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.onap.so.db.request.data.repository; + +import java.util.List; + +import org.onap.so.db.request.beans.ResourceOperationStatus; +import org.onap.so.db.request.beans.ResourceOperationStatusId; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface ResourceOperationStatusRepository extends JpaRepository<ResourceOperationStatus, ResourceOperationStatusId> { + + List<ResourceOperationStatus> findByServiceIdAndOperationId(String serviceId, String operationId); +} diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/SiteStatusRepository.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/SiteStatusRepository.java new file mode 100644 index 0000000000..11923512a5 --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/SiteStatusRepository.java @@ -0,0 +1,31 @@ +/*- + * ============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.onap.so.db.request.data.repository; + +import org.onap.so.db.request.beans.SiteStatus; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface SiteStatusRepository extends JpaRepository<SiteStatus, String> { + SiteStatus findOneBySiteName(String siteName); + +} diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/WatchdogComponentDistributionStatusRepository.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/WatchdogComponentDistributionStatusRepository.java new file mode 100644 index 0000000000..8310d79a5b --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/WatchdogComponentDistributionStatusRepository.java @@ -0,0 +1,34 @@ +/*- + * ============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.onap.so.db.request.data.repository; + +import java.util.List; + +import org.onap.so.db.request.beans.WatchdogComponentDistributionStatus; +import org.onap.so.db.request.beans.WatchdogComponentDistributionStatusId; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface WatchdogComponentDistributionStatusRepository extends JpaRepository<WatchdogComponentDistributionStatus, WatchdogComponentDistributionStatusId> { + + public List<WatchdogComponentDistributionStatus> findByDistributionId(String distributionId); +} diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/WatchdogDistributionStatusRepository.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/WatchdogDistributionStatusRepository.java new file mode 100644 index 0000000000..6e37181380 --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/WatchdogDistributionStatusRepository.java @@ -0,0 +1,30 @@ +/*- + * ============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.onap.so.db.request.data.repository; + +import org.onap.so.db.request.beans.WatchdogDistributionStatus; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface WatchdogDistributionStatusRepository extends JpaRepository<WatchdogDistributionStatus, String> { + +} diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/WatchdogServiceModVerIdLookupRepository.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/WatchdogServiceModVerIdLookupRepository.java new file mode 100644 index 0000000000..b83481b88b --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/WatchdogServiceModVerIdLookupRepository.java @@ -0,0 +1,33 @@ +/*- + * ============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.onap.so.db.request.data.repository; + +import org.onap.so.db.request.beans.WatchdogServiceModVerIdLookup; +import org.onap.so.db.request.beans.WatchdogServiceModVerIdLookupId; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface WatchdogServiceModVerIdLookupRepository extends JpaRepository<WatchdogServiceModVerIdLookup, WatchdogServiceModVerIdLookupId> { + + public WatchdogServiceModVerIdLookup findOneByDistributionId(String distributionId); + +} diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/requestsdb/RequestsDBHelper.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/requestsdb/RequestsDBHelper.java new file mode 100644 index 0000000000..6eb00ea1e9 --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/requestsdb/RequestsDBHelper.java @@ -0,0 +1,107 @@ +/*- + * ============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.onap.so.requestsdb; + +import java.sql.Timestamp; + +import org.onap.so.db.request.beans.InfraActiveRequests; +import org.onap.so.db.request.data.repository.InfraActiveRequestsRepository; +import org.onap.so.logger.MsoLogger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +public class RequestsDBHelper { + + private static final String UNKNOWN = "UNKNOWN"; + private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.APIH, RequestsDBHelper.class); + private String className = this.getClass().getSimpleName() +" class\'s "; + private String methodName = ""; + private String classMethodMessage = ""; + @Autowired + private InfraActiveRequestsRepository infraActiveRequestsRepository; + /** + * 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); + + InfraActiveRequests request = infraActiveRequestsRepository.findOneByRequestId(requestId); + + request.setRequestStatus("COMPLETE"); + request.setStatusMessage("SUCCESSFUL, operationalEnvironmentId - " + operationalEnvironmentId + "; Success Message: " + msg); + request.setProgress(100L); + request.setLastModifiedBy("APIH"); + request.setOperationalEnvId(operationalEnvironmentId); + if(request.getAction() == null){ + request.setRequestAction(UNKNOWN); + } + if(request.getRequestScope() == null){ + request.setRequestScope(UNKNOWN); + } + Timestamp endTimeStamp = new Timestamp(System.currentTimeMillis()); + request.setEndTime(endTimeStamp); + infraActiveRequestsRepository.save(request); + + 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); + + InfraActiveRequests request = infraActiveRequestsRepository.findOneByRequestId(requestId); + request.setRequestStatus("FAILED"); + request.setStatusMessage("FAILURE, operationalEnvironmentId - " + operationalEnvironmentId + "; Error message: " + msg); + request.setProgress(100L); + request.setLastModifiedBy("APIH"); + request.setOperationalEnvId(operationalEnvironmentId); + if(request.getAction() == null){ + request.setRequestAction(UNKNOWN); + } + if(request.getRequestScope() == null){ + request.setRequestScope(UNKNOWN); + } + Timestamp endTimeStamp = new Timestamp(System.currentTimeMillis()); + request.setEndTime(endTimeStamp); + infraActiveRequestsRepository.save(request); + + msoLogger.debug("End of " + classMethodMessage); + + } +} diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/requestsdb/RequestsDbConstant.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/requestsdb/RequestsDbConstant.java new file mode 100644 index 0000000000..60bad3791c --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/requestsdb/RequestsDbConstant.java @@ -0,0 +1,66 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.requestsdb; + +/** + * The constants of the request db + * <br> + * <p> + * </p> + * + * @author + * @version ONAP Amsterdam Release 2017-08-28 + */ +public class RequestsDbConstant { + + public static class Progress { + + public static final String ONE_HUNDRED = "100"; + + private Progress() { + + } + } + + public static class Status { + + public static final String FINISHED = "finished"; + + public static final String PROCESSING = "processing"; + + public static final String ERROR = "error"; + + private Status() { + + } + } + + public static class OperationType { + + public static final String CREATE = "create"; + + public static final String DELETE = "delete"; + + private OperationType() { + + } + } +} diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/requestsdb/adapter/TimestampXMLAdapter.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/requestsdb/adapter/TimestampXMLAdapter.java new file mode 100644 index 0000000000..1cde1aac51 --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/requestsdb/adapter/TimestampXMLAdapter.java @@ -0,0 +1,42 @@ +/*- + * ============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.onap.so.requestsdb.adapter; + + +import java.sql.Timestamp; + +import javax.xml.bind.annotation.adapters.XmlAdapter; + +public class TimestampXMLAdapter extends XmlAdapter <Long, Timestamp> { + + @Override + public Long marshal (Timestamp v) throws Exception { + return v.getTime (); + } + + @Override + public Timestamp unmarshal (Long v) throws Exception { + if (v == null) { + return new Timestamp(0); + } + return new Timestamp (v); + } +} |