diff options
Diffstat (limited to 'mso-api-handlers/mso-requests-db/src')
29 files changed, 1170 insertions, 2149 deletions
diff --git a/mso-api-handlers/mso-requests-db/src/hibernate.reveng.xml b/mso-api-handlers/mso-requests-db/src/hibernate.reveng.xml deleted file mode 100644 index d62640525b..0000000000 --- a/mso-api-handlers/mso-requests-db/src/hibernate.reveng.xml +++ /dev/null @@ -1,30 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - ============LICENSE_START======================================================= - ECOMP MSO - ================================================================================ - Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - ================================================================================ - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - ============LICENSE_END========================================================= - --> - -<!DOCTYPE hibernate-reverse-engineering PUBLIC "-//Hibernate/Hibernate Reverse Engineering DTD 3.0//EN" "http://www.hibernate.org/dtd//hibernate-reverse-engineering-3.0.dtd" > - -<hibernate-reverse-engineering> - <schema-selection match-schema="MSO" /> - <type-mapping> - <sql-type jdbc-type="OTHER" hibernate-type="java.sql.Timestamp" /> - </type-mapping> - <table-filter match-schema="MSO" match-name=".*" /> -</hibernate-reverse-engineering> diff --git a/mso-api-handlers/mso-requests-db/src/main/java/META-INF/MANIFEST.MF b/mso-api-handlers/mso-requests-db/src/main/java/META-INF/MANIFEST.MF deleted file mode 100644 index 5e9495128c..0000000000 --- a/mso-api-handlers/mso-requests-db/src/main/java/META-INF/MANIFEST.MF +++ /dev/null @@ -1,3 +0,0 @@ -Manifest-Version: 1.0
-Class-Path:
-
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 index 924f8870d3..348fc524ef 100644 --- 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 @@ -36,60 +36,59 @@ import org.apache.commons.lang3.builder.ToStringBuilder; @Table(name = "infra_active_requests") public class InfraActiveRequests extends InfraRequests { - private static final long serialVersionUID = -6818265918910035170L; + private static final long serialVersionUID = -6818265918910035170L; - public InfraActiveRequests() { - } + public InfraActiveRequests() {} - public InfraActiveRequests(String requestId, String action) { - setRequestId(requestId); - setAction(action); - } + public InfraActiveRequests(final String requestId, final 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()); - } + public InfraActiveRequests(final String requestId) { + setRequestId(requestId); + } - @Override - public int hashCode() { - return Objects.hash(getRequestId()); - } + @Override + public boolean equals(final Object other) { + if (this == other) { + return true; + } + if (!(other instanceof InfraActiveRequests)) { + return false; + } + final InfraActiveRequests castOther = (InfraActiveRequests) other; + return Objects.equals(getRequestId(), castOther.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(); - } + @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 index 48a6cf3ff0..4a46a0d00d 100644 --- 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 @@ -35,522 +35,522 @@ 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 org.onap.so.requestsdb.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 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; - } + @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 Timestamp getStartTime() { + return this.startTime; + } - public void setStartTime(Timestamp startTime) { - this.startTime = startTime; - } + public void setStartTime(Timestamp startTime) { + this.startTime = startTime; + } @XmlJavaTypeAdapter(TimestampXMLAdapter.class) - public Timestamp getEndTime() { - return this.endTime; - } + 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 void setEndTime(Timestamp endTime) { - this.endTime = endTime; - } + public String getLastModifiedBy() { + return this.lastModifiedBy; + } - public String getSource() { - return this.source; - } + public void setLastModifiedBy(String lastModifiedBy) { + this.lastModifiedBy = lastModifiedBy; + } - 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 Date getModifyTime() { + return this.modifyTime; + } - public String getLastModifiedBy() { - return this.lastModifiedBy; - } + public String getRequestType() { + return this.requestType; + } - public void setLastModifiedBy(String lastModifiedBy) { - this.lastModifiedBy = lastModifiedBy; - } + public void setRequestType(String requestType) { + this.requestType = requestType; + } - public Date getModifyTime() { - return this.modifyTime; - } - - public String getRequestType() { - return this.requestType; - } + public String getVolumeGroupId() { + return this.volumeGroupId; + } - public void setRequestType(String requestType) { - this.requestType = requestType; - } + public void setVolumeGroupId(String volumeGroupId) { + this.volumeGroupId = volumeGroupId; + } - public String getVolumeGroupId() { - return this.volumeGroupId; - } + public String getVolumeGroupName() { + return this.volumeGroupName; + } - public void setVolumeGroupId(String volumeGroupId) { - this.volumeGroupId = volumeGroupId; - } + public void setVolumeGroupName(String volumeGroupName) { + this.volumeGroupName = volumeGroupName; + } - public String getVolumeGroupName() { - return this.volumeGroupName; - } + public String getVfModuleId() { + return this.vfModuleId; + } - public void setVolumeGroupName(String volumeGroupName) { - this.volumeGroupName = volumeGroupName; - } + public void setVfModuleId(String vfModuleId) { + this.vfModuleId = vfModuleId; + } - public String getVfModuleId() { - return this.vfModuleId; - } + public String getVfModuleName() { + return this.vfModuleName; + } - public void setVfModuleId(String vfModuleId) { - this.vfModuleId = vfModuleId; - } + public void setVfModuleName(String vfModuleName) { + this.vfModuleName = vfModuleName; + } - public String getVfModuleName() { - return this.vfModuleName; - } + public String getVfModuleModelName() { + return this.vfModuleModelName; + } - public void setVfModuleName(String vfModuleName) { - this.vfModuleName = vfModuleName; - } + public void setVfModuleModelName(String vfModuleModelName) { + this.vfModuleModelName = vfModuleModelName; + } - public String getVfModuleModelName() { - return this.vfModuleModelName; - } + public String getAaiServiceId() { + return this.aaiServiceId; + } - public void setVfModuleModelName(String vfModuleModelName) { - this.vfModuleModelName = vfModuleModelName; - } + public void setAaiServiceId(String aaiServiceId) { + this.aaiServiceId = aaiServiceId; + } - public String getAaiServiceId() { - return this.aaiServiceId; - } + public String getAicCloudRegion() { + return this.aicCloudRegion; + } - public void setAaiServiceId(String aaiServiceId) { - this.aaiServiceId = aaiServiceId; - } + public void setAicCloudRegion(String aicCloudRegion) { + this.aicCloudRegion = aicCloudRegion; + } - public String getAicCloudRegion() { - return this.aicCloudRegion; - } + public String getCallBackUrl() { + return callBackUrl; + } - public void setAicCloudRegion(String aicCloudRegion) { - this.aicCloudRegion = aicCloudRegion; - } + public void setCallBackUrl(String callBackUrl) { + this.callBackUrl = callBackUrl; + } - public String getCallBackUrl() { - return callBackUrl; - } + public String getCorrelator() { + return correlator; + } - public void setCallBackUrl(String callBackUrl) { - this.callBackUrl = callBackUrl; - } + public void setCorrelator(String correlator) { + this.correlator = correlator; + } - 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(); - } + 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/RequestProcessingData.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/RequestProcessingData.java new file mode 100644 index 0000000000..34832b9917 --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/RequestProcessingData.java @@ -0,0 +1,167 @@ +/*- + * ============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.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.PrePersist; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.ToStringBuilder; + +import com.openpojo.business.annotation.BusinessKey; + +/** + * persist the request identifiers created when MSO POSTs a request to PINC + * <br> + * <p> + * </p> + * + * @author + * @version + */ + +@Entity +@Table(name = "request_processing_data") +public class RequestProcessingData implements Serializable{ + + /** + * + */ + private static final long serialVersionUID = -3497593687393936143L; + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "ID") + private Integer id; + + @BusinessKey + @Column(name = "SO_REQUEST_ID", length=50, unique=true) + private String soRequestId; + + @BusinessKey + @Column(name = "GROUPING_ID", length=100, unique=true) + private String groupingId; + + @BusinessKey + @Column(name = "NAME", length=200) + private String name; + + @Column(name = "VALUE", columnDefinition = "LONGTEXT") + private String value; + + @BusinessKey + @Column(name = "TAG", length=200) + private String tag; + + @Column(name = "CREATE_TIME", insertable = false, updatable = false) + @Temporal(TemporalType.TIMESTAMP) + private Date created = null; + + @Override + public boolean equals(final Object other) { + if (!(other instanceof RequestProcessingData)) { + return false; + } + RequestProcessingData castOther = (RequestProcessingData) other; + return new EqualsBuilder().append(soRequestId, castOther.soRequestId).append(groupingId, castOther.groupingId) + .append(name, castOther.name).append(tag, castOther.tag).isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(soRequestId).append(groupingId).append(name).append(tag).toHashCode(); + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("id", id).append("soRequestId", soRequestId) + .append("groupingId", groupingId).append("name", name).append("value", value).append("tag", tag) + .toString(); + } + + @PrePersist + protected void createdAt() { + this.created = new Date(); + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getSoRequestId() { + return soRequestId; + } + + public void setSoRequestId(String soRequestId) { + this.soRequestId = soRequestId; + } + + public String getGroupingId() { + return groupingId; + } + + public void setGroupingId(String groupingId) { + this.groupingId = groupingId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public String getTag() { + return tag; + } + + public void setTag(String tag) { + this.tag = tag; + } + + public Date getCreated() { + return created; + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java new file mode 100644 index 0000000000..6ab92853d1 --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java @@ -0,0 +1,388 @@ +/*- + * ============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.client; + +import org.apache.http.HttpStatus; +import org.onap.so.db.request.beans.ArchivedInfraRequests; +import org.onap.so.db.request.beans.InfraActiveRequests; +import org.onap.so.db.request.beans.OperationStatus; +import org.onap.so.db.request.beans.OperationalEnvDistributionStatus; +import org.onap.so.db.request.beans.OperationalEnvServiceModelStatus; +import org.onap.so.db.request.beans.RequestProcessingData; +import org.onap.so.db.request.beans.ResourceOperationStatus; +import org.onap.so.db.request.beans.SiteStatus; +import org.onap.so.db.request.beans.WatchdogComponentDistributionStatus; +import org.onap.so.db.request.beans.WatchdogDistributionStatus; +import org.onap.so.db.request.beans.WatchdogServiceModVerIdLookup; +import org.onap.so.db.request.data.controller.InstanceNameDuplicateCheckRequest; +import org.onap.so.logging.jaxrs.filter.SpringClientFilter; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Primary; +import org.springframework.core.ParameterizedTypeReference; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpRequest; +import org.springframework.http.client.BufferingClientHttpRequestFactory; +import org.springframework.http.client.ClientHttpRequestExecution; +import org.springframework.http.client.ClientHttpRequestFactory; +import org.springframework.http.client.ClientHttpRequestInterceptor; +import org.springframework.http.client.ClientHttpResponse; +import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; +import org.springframework.stereotype.Component; +import org.springframework.web.client.HttpClientErrorException; +import org.springframework.web.client.RestTemplate; +import uk.co.blackpepper.bowman.Client; +import uk.co.blackpepper.bowman.ClientFactory; +import uk.co.blackpepper.bowman.Configuration; +import uk.co.blackpepper.bowman.RestTemplateConfigurer; + +import javax.annotation.PostConstruct; +import javax.ws.rs.core.UriBuilder; +import java.io.IOException; +import java.net.URI; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +@Component("RequestsDbClient") +@Primary +public class RequestsDbClient { + + private static final String SERVICE_ID = "SERVICE_ID"; + private static final String OPERATION_ID = "OPERATION_ID"; + private static final String SO_REQUEST_ID = "SO_REQUEST_ID"; + private static final String GROUPING_ID = "GROUPING_ID"; + private static final String REQUEST_ID = "REQUEST_ID"; + private static final String OPERATIONAL_ENVIRONMENT_ID = "OPERATIONAL_ENVIRONMENT_ID"; + private static final String SERVICE_MODEL_VERSION_ID = "SERVICE_MODEL_VERSION_ID"; + private static final String NAME = "NAME"; + private static final String VALUE = "VALUE"; + private static final String TAG = "TAG"; + + + @Value("${mso.adapters.requestDb.endpoint}") + protected String endpoint; + + @Value("${mso.adapters.requestDb.auth}") + private String msoAdaptersAuth; + + private String getOrchestrationFilterURI = "/infraActiveRequests/getOrchestrationFiltersFromInfraActive/"; + private static final String OPERATION_STATUS_SEARCH = "/operationStatus/search"; + private static final String OPERATIONAL_ENV_SERVICE_MODEL_STATUS_SEARCH = "/operationalEnvServiceModelStatus/search"; + + + private String checkVnfIdStatus = "/infraActiveRequests/checkVnfIdStatus/"; + + private String infraActiveRequestURI = "/infraActiveRequests/"; + + private String checkInstanceNameDuplicate = "/infraActiveRequests/checkInstanceNameDuplicate"; + + private String operationalEnvDistributionStatusURI = "/operationalEnvDistributionStatus/"; + + private String findOneByServiceIdAndOperationIdURI = "/findOneByServiceIdAndOperationId"; + + private String findOneByOperationalEnvIdAndServiceModelVersionIdURI = "/findOneByOperationalEnvIdAndServiceModelVersionId"; + + private String findAllByOperationalEnvIdAndRequestIdURI = "/findAllByOperationalEnvIdAndRequestId"; + + private String cloudOrchestrationFiltersFromInfraActive = "/infraActiveRequests/getCloudOrchestrationFiltersFromInfraActive"; + + private String requestProcessingDataURI = "/requestProcessingData"; + + private String findOneBySoRequestIdAndGroupingIdAndNameAndTagURI = "/requestProcessingData/search/findOneBySoRequestIdAndGroupingIdAndNameAndTag/"; + + private String findBySoRequestIdOrderByGroupingIdDesc = "/requestProcessingData/search/findBySoRequestIdOrderByGroupingIdDesc/"; + + + @Autowired + protected RestTemplate restTemplate; + + @Autowired + ClassURLMapper classURLMapper; + + @PostConstruct + public void init() { + getOrchestrationFilterURI = endpoint + getOrchestrationFilterURI; + infraActiveRequestURI = endpoint + infraActiveRequestURI; + checkVnfIdStatus = endpoint + checkVnfIdStatus; + checkInstanceNameDuplicate = endpoint + checkInstanceNameDuplicate; + cloudOrchestrationFiltersFromInfraActive = endpoint + cloudOrchestrationFiltersFromInfraActive; + findOneByServiceIdAndOperationIdURI = endpoint + OPERATION_STATUS_SEARCH + findOneByServiceIdAndOperationIdURI; + requestProcessingDataURI = endpoint + requestProcessingDataURI; + operationalEnvDistributionStatusURI = endpoint + operationalEnvDistributionStatusURI; + findOneByOperationalEnvIdAndServiceModelVersionIdURI = endpoint + OPERATIONAL_ENV_SERVICE_MODEL_STATUS_SEARCH + findOneByOperationalEnvIdAndServiceModelVersionIdURI; + findAllByOperationalEnvIdAndRequestIdURI = endpoint + OPERATIONAL_ENV_SERVICE_MODEL_STATUS_SEARCH + findAllByOperationalEnvIdAndRequestIdURI; + } + + public ClientFactory getClientFactory(){ + URI baseUri = UriBuilder.fromUri(endpoint).build(); + ClientHttpRequestFactory factory = new BufferingClientHttpRequestFactory(new HttpComponentsClientHttpRequestFactory()); + + return Configuration.builder().setBaseUri(baseUri).setClientHttpRequestFactory(factory).setRestTemplateConfigurer(restTemplate -> { + restTemplate.getInterceptors().add((new SpringClientFilter())); + + restTemplate.getInterceptors().add((request, body, execution) -> { + + request.getHeaders().add(HttpHeaders.AUTHORIZATION, msoAdaptersAuth); + return execution.execute(request, body); + }); + }).build().buildClientFactory(); + } + + + public List<InfraActiveRequests> getCloudOrchestrationFiltersFromInfraActive(Map<String, String> orchestrationMap){ + URI uri = getUri(cloudOrchestrationFiltersFromInfraActive); + HttpHeaders headers = new HttpHeaders(); + headers.set("Authorization", msoAdaptersAuth); + HttpEntity<Map> entity = new HttpEntity<>(orchestrationMap, headers); + try{ + return restTemplate.exchange(uri, HttpMethod.POST, entity, new ParameterizedTypeReference<List<InfraActiveRequests>>() {}).getBody(); + }catch(HttpClientErrorException e){ + if(HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()){ + return null; + } + throw e; + } + } + + public InfraActiveRequests getInfraActiveRequestbyRequestId(String requestId) { + try { + HttpHeaders headers = new HttpHeaders(); + headers.set("Authorization", msoAdaptersAuth); + HttpEntity<?> entity = new HttpEntity<>(headers); + InfraActiveRequests infraActiveRequests = restTemplate.exchange(getUri(endpoint + "/infraActiveRequests/" + requestId), HttpMethod.GET, entity, InfraActiveRequests.class).getBody(); + if (infraActiveRequests != null) { + infraActiveRequests.setRequestId(requestId); + } + return infraActiveRequests; + } catch (HttpClientErrorException e) { + if (HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()) { + return null; + } + throw e; + } + } + + public List<InfraActiveRequests> getOrchestrationFiltersFromInfraActive(Map<String, List<String>> orchestrationMap) { + HttpHeaders headers = new HttpHeaders(); + headers.set("Authorization", msoAdaptersAuth); + URI uri = getUri(getOrchestrationFilterURI); + HttpEntity<Map<String, List<String>>> entity = new HttpEntity<>(orchestrationMap, headers); + return restTemplate.exchange(uri, HttpMethod.POST, entity, new ParameterizedTypeReference<List<InfraActiveRequests>>() {}).getBody(); + } + + public InfraActiveRequests checkVnfIdStatus(String operationalEnvironmentId) { + HttpHeaders headers = new HttpHeaders(); + headers.set("Authorization", msoAdaptersAuth); + HttpEntity<?> entity = new HttpEntity<>(headers); + URI uri = getUri(checkVnfIdStatus + operationalEnvironmentId); + return restTemplate.exchange(uri, HttpMethod.GET, entity, InfraActiveRequests.class).getBody(); + } + + public InfraActiveRequests checkInstanceNameDuplicate(HashMap<String, String> instanceIdMap, String instanceName, String requestScope) { + HttpHeaders headers = new HttpHeaders(); + headers.set("Authorization", msoAdaptersAuth); + URI uri = getUri(checkInstanceNameDuplicate); + HttpEntity<InstanceNameDuplicateCheckRequest> entity = new HttpEntity<>(new InstanceNameDuplicateCheckRequest(instanceIdMap, instanceName, requestScope), headers); + try{ + return restTemplate.exchange(uri, HttpMethod.POST, entity, InfraActiveRequests.class).getBody(); + }catch(HttpClientErrorException e){ + if(HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()){ + return null; + } + throw e; + } + + } + + public OperationStatus getOneByServiceIdAndOperationId(String serviceId, String operationId) { + try { + HttpHeaders headers = new HttpHeaders(); + headers.set("Authorization", msoAdaptersAuth); + HttpEntity<?> entity = new HttpEntity<>(headers); + OperationStatus operationStatus = restTemplate.exchange(UriBuilder.fromUri(getUri(findOneByServiceIdAndOperationIdURI)) + .queryParam(SERVICE_ID, serviceId) + .queryParam(OPERATION_ID, operationId) + .build(), HttpMethod.GET, entity, OperationStatus.class).getBody(); + if (operationStatus != null) { + operationStatus.setServiceId(serviceId); + operationStatus.setOperationId(operationId); + } + + return operationStatus; + } catch (HttpClientErrorException e) { + if (HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()) { + return null; + } + throw e; + } + } + + public OperationalEnvServiceModelStatus findOneByOperationalEnvIdAndServiceModelVersionId(String operationalEnvironmentId, String serviceModelVersionId) { + return this.getSingleOperationalEnvServiceModelStatus(UriBuilder.fromUri(findOneByOperationalEnvIdAndServiceModelVersionIdURI) + .queryParam(OPERATIONAL_ENVIRONMENT_ID,operationalEnvironmentId) + .queryParam(SERVICE_MODEL_VERSION_ID,serviceModelVersionId) + .build()); + } + + public List<OperationalEnvServiceModelStatus> getAllByOperationalEnvIdAndRequestId(String operationalEnvironmentId, String requestId){ + return this.getMultipleOperationalEnvServiceModelStatus(UriBuilder.fromUri(findAllByOperationalEnvIdAndRequestIdURI) + .queryParam(OPERATIONAL_ENVIRONMENT_ID,operationalEnvironmentId) + .queryParam(REQUEST_ID,requestId) + .build()); + } + + public OperationalEnvDistributionStatus getDistributionStatusById(String distributionId){ + return this.getSingleOperationalEnvDistributionStatus(UriBuilder.fromUri(operationalEnvDistributionStatusURI+distributionId).build()); + } + + private OperationalEnvServiceModelStatus getSingleOperationalEnvServiceModelStatus(URI uri){ + return getClientFactory().create(OperationalEnvServiceModelStatus.class).get(uri); + } + + private List<OperationalEnvServiceModelStatus> getMultipleOperationalEnvServiceModelStatus(URI uri){ + Iterable <OperationalEnvServiceModelStatus> iterable = getClientFactory().create(OperationalEnvServiceModelStatus.class).getAll(uri); + List<OperationalEnvServiceModelStatus> serviceModelStatuses = new ArrayList<>(); + Iterator<OperationalEnvServiceModelStatus> statusIterator = iterable.iterator(); + statusIterator.forEachRemaining(serviceModelStatuses::add); + return serviceModelStatuses; + } + + public void save(InfraActiveRequests infraActiveRequests) { + HttpHeaders headers = new HttpHeaders(); + headers.set("Authorization", msoAdaptersAuth); + URI uri = getUri(infraActiveRequestURI); + HttpEntity<InfraActiveRequests> entity = new HttpEntity<>(infraActiveRequests, headers); + restTemplate.postForLocation(uri, entity); + } + + public <T> void save(T object){ + HttpHeaders headers = new HttpHeaders(); + headers.set("Authorization", msoAdaptersAuth); + URI uri = getUri(endpoint+classURLMapper.getURI(object.getClass())); + HttpEntity<T> entity = new HttpEntity<>(object, headers); + restTemplate.postForLocation(uri, entity); + } + + private OperationalEnvDistributionStatus getSingleOperationalEnvDistributionStatus(URI uri){ + return getClientFactory().create(OperationalEnvDistributionStatus.class).get(uri); + } + + public void updateInfraActiveRequests(InfraActiveRequests request) { + HttpHeaders headers = new HttpHeaders(); + headers.set("Authorization", msoAdaptersAuth); + headers.set(HttpHeaders.CONTENT_TYPE,"application/json"); + headers.set(HttpHeaders.ACCEPT, "application/json"); + URI uri = getUri(infraActiveRequestURI+request.getRequestId()); + HttpEntity<InfraActiveRequests> entity = new HttpEntity<>(request, headers); + restTemplate.put(uri, entity); + } + + protected URI getUri(String uri) { + return URI.create(uri); + } + + public void saveRequestProcessingData(RequestProcessingData requestProcessingData) { + HttpHeaders headers = new HttpHeaders(); + headers.set("Authorization", msoAdaptersAuth); + URI uri = getUri(endpoint + requestProcessingDataURI); + HttpEntity<RequestProcessingData> entity = new HttpEntity<>(requestProcessingData, headers); + restTemplate.postForLocation(uri, entity); + } + + public RequestProcessingData getRequestProcessingDataBySoRequestIdAndGroupingIdAndNameAndTag(String soRequestId, + String groupingId, String name, String tag) { + return this.getSingleRequestProcessingData(UriBuilder.fromUri(endpoint + findOneBySoRequestIdAndGroupingIdAndNameAndTagURI) + .queryParam(SO_REQUEST_ID,soRequestId) + .queryParam(GROUPING_ID,groupingId) + .queryParam(NAME,name) + .queryParam(TAG,tag) + .build()); + } + public List<RequestProcessingData> getRequestProcessingDataBySoRequestId(String soRequestId) { + return this.getRequestProcessingData(UriBuilder.fromUri(endpoint + findBySoRequestIdOrderByGroupingIdDesc) + .queryParam(SO_REQUEST_ID,soRequestId) + .build()); + } + + public RequestProcessingData getSingleRequestProcessingData(URI uri){ + return getClientFactory().create(RequestProcessingData.class).get(uri); + } + + private List<RequestProcessingData> getRequestProcessingData(URI uri) { + Iterable<RequestProcessingData> requestProcessingDataIterator = getClientFactory().create(RequestProcessingData.class).getAll(uri); + List<RequestProcessingData> requestProcessingDataList = new ArrayList<>(); + Iterator<RequestProcessingData> it = requestProcessingDataIterator.iterator(); + it.forEachRemaining(requestProcessingDataList::add); + return requestProcessingDataList; + } + + public List<RequestProcessingData> getAllRequestProcessingData() { + + return (List<RequestProcessingData>) this.getAllRequestProcessingData(UriBuilder.fromUri(endpoint + "/requestProcessingData").build()); + } + + private Iterable<RequestProcessingData> getAllRequestProcessingData(URI uri) { + return getClientFactory().create(RequestProcessingData.class).getAll(uri); + } + + @Component + static class ClassURLMapper { + private static final Map <Class,String> classURLMap = new HashMap<>(); + + ClassURLMapper() { + classURLMap.put(ArchivedInfraRequests.class,"/archivedInfraRequests/"); + classURLMap.put(InfraActiveRequests.class,"/infraActiveRequests/"); + classURLMap.put(OperationalEnvDistributionStatus.class,"/operationalEnvDistributionStatus/"); + classURLMap.put(OperationalEnvServiceModelStatus.class,"/operationalEnvServiceModelStatus/"); + classURLMap.put(OperationStatus.class,"/operationStatus/"); + classURLMap.put(ResourceOperationStatus.class,"/resourceOperationStatus/"); + classURLMap.put(SiteStatus.class,"/siteStatus/"); + classURLMap.put(WatchdogComponentDistributionStatus.class,"/watchdogComponentDistributionStatus/"); + classURLMap.put(WatchdogDistributionStatus.class,"/watchdogDistributionStatus/"); + classURLMap.put(WatchdogServiceModVerIdLookup.class,"/watchdogServiceModVerIdLookup/"); + } + + <T> String getURI(Class<T> className) { + Class actualClass = classURLMap.keySet() + .stream() + .filter(requestdbClass -> requestdbClass.isAssignableFrom(className)) + .findFirst() + .get(); + return classURLMap.get(actualClass); + } + } + + //USED FOR TEST ONLY + public void setPortToEndpoint(String port) { + endpoint = endpoint + port; + } + + //USED FOR TEST ONLY + public void removePortFromEndpoint() { + endpoint = endpoint.substring(0, endpoint.lastIndexOf(':') + 1); + } +} 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 deleted file mode 100644 index f3e92ed16a..0000000000 --- a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/ArchivedInfraRequestsRepository.java +++ /dev/null @@ -1,30 +0,0 @@ -/*- - * ============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 deleted file mode 100644 index cd25b122be..0000000000 --- a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepository.java +++ /dev/null @@ -1,41 +0,0 @@ -/*- - * ============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 deleted file mode 100644 index ba237bfa35..0000000000 --- a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryCustom.java +++ /dev/null @@ -1,57 +0,0 @@ -/*- - * ============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 deleted file mode 100644 index 3240972a58..0000000000 --- a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImpl.java +++ /dev/null @@ -1,566 +0,0 @@ -/*- - * ============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 deleted file mode 100644 index 22a1604bdd..0000000000 --- a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/OperationStatusRepository.java +++ /dev/null @@ -1,35 +0,0 @@ -/*- - * ============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.data.repository.query.Param; -import org.springframework.data.rest.core.annotation.RepositoryRestResource; - -@RepositoryRestResource(collectionResourceRel = "operationStatusRepository", path = "operationStatusRepository") -public interface OperationStatusRepository extends JpaRepository<OperationStatus, OperationStatusId> { - - OperationStatus findOneByServiceIdAndOperationId(@Param("SERVICE_ID") String serviceId, @Param("OPERATION_ID") 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 deleted file mode 100644 index 799e5ad147..0000000000 --- a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/OperationalEnvDistributionStatusRepository.java +++ /dev/null @@ -1,42 +0,0 @@ -/*- - * ============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 deleted file mode 100644 index ee2baedf61..0000000000 --- a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/OperationalEnvServiceModelStatusRepository.java +++ /dev/null @@ -1,59 +0,0 @@ -/*- - * ============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/QueryOperationType.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/QueryOperationType.java new file mode 100644 index 0000000000..4aaa8d2cbe --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/QueryOperationType.java @@ -0,0 +1,69 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2018 Ericsson. 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.db.request.data.repository; + +import javax.persistence.criteria.CriteriaBuilder; +import javax.persistence.criteria.Predicate; +import javax.persistence.criteria.Root; + +/** + * @author waqas.ikram@ericsson.com + */ +public enum QueryOperationType { + + EQ { + @Override + public <T> Predicate getPredicate(final CriteriaBuilder criteriaBuilder, final Root<T> tableRoot, + final String key, final String value) { + return criteriaBuilder.equal(tableRoot.get(key), value); + } + + }, + NEQ { + + @Override + public <T> Predicate getPredicate(final CriteriaBuilder criteriaBuilder, final Root<T> tableRoot, + final String key, final String value) { + return criteriaBuilder.notEqual(tableRoot.get(key), value); + } + + }, + LIKE { + + @Override + public <T> Predicate getPredicate(final CriteriaBuilder criteriaBuilder, final Root<T> tableRoot, + final String key, final String value) { + return criteriaBuilder.like(tableRoot.get(key), "%" + value + "%"); + } + }; + + public static QueryOperationType getQueryOperationType(final String type) { + for (final QueryOperationType queryOperationType : QueryOperationType.values()) { + if (queryOperationType.name().equalsIgnoreCase(type)) { + return queryOperationType; + } + } + return QueryOperationType.EQ; + } + + public abstract <T> Predicate getPredicate(final CriteriaBuilder criteriaBuilder, final Root<T> tableRoot, + final String key, final String value); + +} 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 deleted file mode 100644 index 2d77f7589e..0000000000 --- a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/ResourceOperationStatusRepository.java +++ /dev/null @@ -1,34 +0,0 @@ -/*- - * ============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 deleted file mode 100644 index 11923512a5..0000000000 --- a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/SiteStatusRepository.java +++ /dev/null @@ -1,31 +0,0 @@ -/*- - * ============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 deleted file mode 100644 index 8310d79a5b..0000000000 --- a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/WatchdogComponentDistributionStatusRepository.java +++ /dev/null @@ -1,34 +0,0 @@ -/*- - * ============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 deleted file mode 100644 index 6e37181380..0000000000 --- a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/WatchdogDistributionStatusRepository.java +++ /dev/null @@ -1,30 +0,0 @@ -/*- - * ============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 deleted file mode 100644 index b83481b88b..0000000000 --- a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/WatchdogServiceModVerIdLookupRepository.java +++ /dev/null @@ -1,33 +0,0 @@ -/*- - * ============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 index 6eb00ea1e9..ea3ef30827 100644 --- 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 @@ -23,9 +23,10 @@ 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.onap.so.db.request.client.RequestsDbClient; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Component; @Component @@ -37,7 +38,8 @@ public class RequestsDBHelper { private String methodName = ""; private String classMethodMessage = ""; @Autowired - private InfraActiveRequestsRepository infraActiveRequestsRepository; + @Qualifier("RequestsDbClient") + private RequestsDbClient requestsDbClient; /** * This util method is to update the InfraRequest table to Complete * @param msg - string, unique message for each caller @@ -51,7 +53,7 @@ public class RequestsDBHelper { classMethodMessage = className + " " + methodName; msoLogger.debug("Begin of " + classMethodMessage); - InfraActiveRequests request = infraActiveRequestsRepository.findOneByRequestId(requestId); + InfraActiveRequests request = requestsDbClient.getInfraActiveRequestbyRequestId(requestId); request.setRequestStatus("COMPLETE"); request.setStatusMessage("SUCCESSFUL, operationalEnvironmentId - " + operationalEnvironmentId + "; Success Message: " + msg); @@ -66,7 +68,7 @@ public class RequestsDBHelper { } Timestamp endTimeStamp = new Timestamp(System.currentTimeMillis()); request.setEndTime(endTimeStamp); - infraActiveRequestsRepository.save(request); + requestsDbClient.save(request); msoLogger.debug("End of " + classMethodMessage); @@ -85,7 +87,7 @@ public class RequestsDBHelper { classMethodMessage = className + " " + methodName; msoLogger.debug("Begin of " + classMethodMessage); - InfraActiveRequests request = infraActiveRequestsRepository.findOneByRequestId(requestId); + InfraActiveRequests request = requestsDbClient.getInfraActiveRequestbyRequestId(requestId); request.setRequestStatus("FAILED"); request.setStatusMessage("FAILURE, operationalEnvironmentId - " + operationalEnvironmentId + "; Error message: " + msg); request.setProgress(100L); @@ -99,7 +101,7 @@ public class RequestsDBHelper { } Timestamp endTimeStamp = new Timestamp(System.currentTimeMillis()); request.setEndTime(endTimeStamp); - infraActiveRequestsRepository.save(request); + requestsDbClient.save(request); msoLogger.debug("End of " + classMethodMessage); 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/TimestampXMLAdapter.java index 1cde1aac51..3a326598a7 100644 --- 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/TimestampXMLAdapter.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.requestsdb.adapter; +package org.onap.so.requestsdb; import java.sql.Timestamp; diff --git a/mso-api-handlers/mso-requests-db/src/main/resources/beans.xml b/mso-api-handlers/mso-requests-db/src/main/resources/beans.xml deleted file mode 100644 index cd1bc8b7d7..0000000000 --- a/mso-api-handlers/mso-requests-db/src/main/resources/beans.xml +++ /dev/null @@ -1,12 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<beans xmlns="http://www.springframework.org/schema/beans" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns:jpa="http://www.springframework.org/schema/data/jpa" - xsi:schemaLocation="http://www.springframework.org/schema/beans - http://www.springframework.org/schema/beans/spring-beans.xsd - http://www.springframework.org/schema/data/jpa - http://www.springframework.org/schema/data/jpa/spring-jpa.xsd"> - - <jpa:repositories base-package="org.onap.so.db.request.data.repository" /> - -</beans>
\ No newline at end of file diff --git a/mso-api-handlers/mso-requests-db/src/test/java/org/onap/so/TestApplication.java b/mso-api-handlers/mso-requests-db/src/test/java/org/onap/so/TestApplication.java deleted file mode 100644 index ec2c41bf8c..0000000000 --- a/mso-api-handlers/mso-requests-db/src/test/java/org/onap/so/TestApplication.java +++ /dev/null @@ -1,35 +0,0 @@ -/*- - * ============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; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Profile; - -@SpringBootApplication(scanBasePackages = { "org.onap" }) -@Profile("test") -public class TestApplication { - public static void main(String... args) { - SpringApplication.run(TestApplication.class, args); - System.getProperties().setProperty("mso.db", "MARIADB"); - System.getProperties().setProperty("server.name", "Springboot"); - } -} diff --git a/mso-api-handlers/mso-requests-db/src/test/java/org/onap/so/db/request/OperationStatusTest.java b/mso-api-handlers/mso-requests-db/src/test/java/org/onap/so/db/request/OperationStatusTest.java deleted file mode 100644 index a10d948b8f..0000000000 --- a/mso-api-handlers/mso-requests-db/src/test/java/org/onap/so/db/request/OperationStatusTest.java +++ /dev/null @@ -1,82 +0,0 @@ -/*- - * ============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; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; - -import java.util.Date; - -import javax.transaction.Transactional; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.onap.so.TestApplication; -import org.onap.so.db.request.beans.OperationStatus; -import org.onap.so.db.request.beans.OperationStatusId; -import org.onap.so.db.request.data.repository.OperationStatusRepository; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.junit4.SpringRunner; - -@RunWith(SpringRunner.class) -@SpringBootTest(classes = TestApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) -@ActiveProfiles("test") -public class OperationStatusTest { - - @Autowired - private OperationStatusRepository repository; - - @Test - @Transactional - public void timeStampCreated() throws InterruptedException { - - final String testServiceId = "test-service-id"; - final String testOperationId = "test-operation-id"; - final OperationStatusId id = new OperationStatusId(testServiceId, testOperationId); - OperationStatus status = new OperationStatus(); - - status.setServiceId(testServiceId); - status.setOperationId(testOperationId); - - status = repository.saveAndFlush(status); - - OperationStatus found = repository.findOne(id); - - Date operateAt = found.getOperateAt(); - assertNotNull(operateAt); - assertEquals(testServiceId, found.getServiceId()); - Date finishedAt = found.getFinishedAt(); - status.setProgress("test-progress"); - //timestamps only set to save on 1 second changes - Thread.sleep(1000); - repository.saveAndFlush(status); - - OperationStatus foundUpdate = repository.findOne(id); - - assertEquals(operateAt.toString(), foundUpdate.getOperateAt().toString()); - assertNotNull(foundUpdate.getFinishedAt()); - assertNotEquals(finishedAt.toString(), foundUpdate.getFinishedAt().toString()); - assertEquals("test-progress", foundUpdate.getProgress()); - } -} diff --git a/mso-api-handlers/mso-requests-db/src/test/java/org/onap/so/db/request/OperationalEnvServiceModelStatusTest.java b/mso-api-handlers/mso-requests-db/src/test/java/org/onap/so/db/request/OperationalEnvServiceModelStatusTest.java deleted file mode 100644 index c12d3cbb7b..0000000000 --- a/mso-api-handlers/mso-requests-db/src/test/java/org/onap/so/db/request/OperationalEnvServiceModelStatusTest.java +++ /dev/null @@ -1,80 +0,0 @@ -/*- - * ============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; - -import static org.junit.Assert.assertEquals; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.onap.so.TestApplication; -import org.onap.so.db.request.beans.OperationalEnvServiceModelStatus; -import org.onap.so.db.request.data.repository.OperationalEnvServiceModelStatusRepository; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.data.domain.Example; -import org.springframework.data.domain.ExampleMatcher; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.junit4.SpringRunner; - -@RunWith(SpringRunner.class) -@SpringBootTest(classes = TestApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) -@ActiveProfiles("test") -public class OperationalEnvServiceModelStatusTest { - - @Autowired - private OperationalEnvServiceModelStatusRepository repository; - - - @Test - public void updateWithoutAllKeys() throws Exception { - - OperationalEnvServiceModelStatus status = new OperationalEnvServiceModelStatus(); - status.setRequestId("request-id-1"); - status.setOperationalEnvId("oper-env-id-1"); - status.setServiceModelVersionId("service-model-ver-id-1"); - status.setRetryCount(0); - - repository.saveAndFlush(status); - OperationalEnvServiceModelStatus status2 = repository.findOneByOperationalEnvIdAndServiceModelVersionId("oper-env-id-1", "service-model-ver-id-1"); - status2.setRetryCount(1); - - repository.saveAndFlush(status2); - - OperationalEnvServiceModelStatus status3 = new OperationalEnvServiceModelStatus(); - - status3.setRequestId("request-id-2"); - status3.setOperationalEnvId("oper-env-id-1"); - status3.setServiceModelVersionId("service-model-ver-id-2"); - status3.setRetryCount(2); - - repository.saveAndFlush(status3); - - OperationalEnvServiceModelStatus exampleObj = new OperationalEnvServiceModelStatus(); - exampleObj.setOperationalEnvId("oper-env-id-1"); - exampleObj.setServiceModelVersionId("service-model-ver-id-1"); - ExampleMatcher matcher = ExampleMatcher.matching().withIgnorePaths("requestId"); - OperationalEnvServiceModelStatus foundStatus = repository.findOne(Example.of(exampleObj,matcher)); - if(foundStatus== null) - throw new Exception("No status found"); - - assertEquals(new Integer(1), foundStatus.getRetryCount()); - } -} diff --git a/mso-api-handlers/mso-requests-db/src/test/java/org/onap/so/db/request/RequestDBConfig.java b/mso-api-handlers/mso-requests-db/src/test/java/org/onap/so/db/request/RequestDBConfig.java deleted file mode 100644 index 9bcff13699..0000000000 --- a/mso-api-handlers/mso-requests-db/src/test/java/org/onap/so/db/request/RequestDBConfig.java +++ /dev/null @@ -1,77 +0,0 @@ -/*- - * ============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; - - -import javax.persistence.EntityManagerFactory; -import javax.sql.DataSource; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Primary; -import org.springframework.data.jpa.repository.config.EnableJpaRepositories; -import org.springframework.orm.jpa.JpaTransactionManager; -import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; -import org.springframework.transaction.PlatformTransactionManager; -import org.springframework.transaction.annotation.EnableTransactionManagement; - -@Configuration -@EnableTransactionManagement -@EnableJpaRepositories( - entityManagerFactoryRef = "requestEntityManagerFactory",transactionManagerRef = "requestTransactionManager", - basePackages = { "org.onap.so.db.request.data.repository" } - ) -public class RequestDBConfig { - - @Primary - @Bean(name = "requestDataSource") - @ConfigurationProperties(prefix = "spring.datasource") - public DataSource dataSource() { - return DataSourceBuilder.create().build(); - } - - @Primary - @Bean(name = "requestEntityManagerFactory") - public LocalContainerEntityManagerFactoryBean - entityManagerFactory( - EntityManagerFactoryBuilder builder, - @Qualifier("requestDataSource") DataSource dataSource - ) { - return builder - .dataSource(dataSource) - .packages("org.onap.so.db.request.beans") - .persistenceUnit("requestDB") - .build(); - } - - @Primary - @Bean(name = "requestTransactionManager") - public PlatformTransactionManager transactionManager( - @Qualifier("requestEntityManagerFactory") EntityManagerFactory - entityManagerFactory - ) { - return new JpaTransactionManager(entityManagerFactory); - } - -} diff --git a/mso-api-handlers/mso-requests-db/src/test/java/org/onap/so/db/request/SiteStatusTest.java b/mso-api-handlers/mso-requests-db/src/test/java/org/onap/so/db/request/SiteStatusTest.java deleted file mode 100644 index 917f52d4ad..0000000000 --- a/mso-api-handlers/mso-requests-db/src/test/java/org/onap/so/db/request/SiteStatusTest.java +++ /dev/null @@ -1,86 +0,0 @@ -/*- - * ============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; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import javax.transaction.Transactional; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.onap.so.TestApplication; -import org.onap.so.db.request.beans.SiteStatus; -import org.onap.so.db.request.data.repository.SiteStatusRepository; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.data.domain.Example; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.PageRequest; -import org.springframework.data.domain.Sort.Direction; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.junit4.SpringRunner; - -@RunWith(SpringRunner.class) -@SpringBootTest(classes = TestApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) -@ActiveProfiles("test") -public class SiteStatusTest { - - @Autowired - private SiteStatusRepository repository; - - @Test - @Transactional - public void timeStampCreated() throws InterruptedException { - SiteStatus found = repository.findOne("test name4"); - assertNotNull(found.getCreated()); - assertEquals("test name4", found.getSiteName()); - } - - @Test - public void sortByCreated() { - - final PageRequest page1 = new PageRequest( - 0, 20, Direction.DESC, "created" - ); - - SiteStatus example = new SiteStatus(); - example.setStatus(true); - Page<SiteStatus> found = repository.findAll(Example.of(example), page1); - - assertEquals("test name4", found.getContent().get(0).getSiteName()); - - } - - @Test - public void updateStatus() { - - SiteStatus status = repository.findOne("test name update"); - status.setStatus(false); - - repository.saveAndFlush(status); - - assertEquals(false, repository.findOne("test name update").getStatus()); - - } - -} diff --git a/mso-api-handlers/mso-requests-db/src/test/resources/application-test.yaml b/mso-api-handlers/mso-requests-db/src/test/resources/application-test.yaml index c8e90c3d8b..c4dd60356b 100644 --- a/mso-api-handlers/mso-requests-db/src/test/resources/application-test.yaml +++ b/mso-api-handlers/mso-requests-db/src/test/resources/application-test.yaml @@ -6,8 +6,13 @@ server: max-threads: 50 ssl-enable: false mso: + adapters: + requestDb: + auth: Basic YnBlbDptc28tZGItMTUwNyE= + endpoint: http://localhost:8081 site-name: localDevEnv logPath: logs + # H2 spring: datasource: diff --git a/mso-api-handlers/mso-requests-db/src/test/resources/schema.sql b/mso-api-handlers/mso-requests-db/src/test/resources/schema.sql deleted file mode 100644 index a01153a43c..0000000000 --- a/mso-api-handlers/mso-requests-db/src/test/resources/schema.sql +++ /dev/null @@ -1,212 +0,0 @@ - -create table ACTIVATE_OPERATIONAL_ENV_SERVICE_MODEL_DISTRIBUTION_STATUS ( - REQUEST_ID varchar(255) not null, - OPERATIONAL_ENV_ID varchar(255) not null, - SERVICE_MODEL_VERSION_ID varchar(255) not null, - SERVICE_MOD_VER_FINAL_DISTR_STATUS varchar(255), - RECOVERY_ACTION varchar(255), - RETRY_COUNT_LEFT varchar(255), - WORKLOAD_CONTEXT varchar(255), - CREATE_TIME datetime, - MODIFY_TIME datetime, - primary key (REQUEST_ID,OPERATIONAL_ENV_ID, SERVICE_MODEL_VERSION_ID) - ); - -create table OPERATION_STATUS ( - SERVICE_ID varchar(255) not null, - OPERATION_ID varchar(255) not null, - SERVICE_NAME varchar(255), - OPERATION_TYPE varchar(255), - USER_ID varchar(255), - RESULT varchar(255), - OPERATION_CONTENT varchar(255), - PROGRESS varchar(255), - REASON varchar(255), - OPERATE_AT datetime, - FINISHED_AT datetime, - primary key (SERVICE_ID,OPERATION_ID) - ); - - -INSERT INTO PUBLIC.OPERATION_STATUS(SERVICE_ID, OPERATION_ID, OPERATION_TYPE, USER_ID, RESULT, OPERATION_CONTENT, PROGRESS, REASON, OPERATE_AT, FINISHED_AT) VALUES -('serviceId', 'operationId', 'operationType', 'userId', 'result', 'operationContent', 'progress', 'reason', '2016-11-24 13:19:10', '2016-11-24 13:19:10'); - - create table RESOURCE_OPERATION_STATUS ( - SERVICE_ID varchar(255) not null, - OPERATION_ID varchar(255) not null, - RESOURCE_TEMPLATE_UUID varchar(255) not null, - OPER_TYPE varchar(255), - RESOURCE_INSTANCE_ID varchar(255), - JOB_ID varchar(255), - STATUS varchar(255), - PROGRESS varchar(255), - ERROR_CODE varchar(255) , - STATUS_DESCRIPOTION varchar(255) , - primary key (SERVICE_ID,OPERATION_ID,RESOURCE_TEMPLATE_UUID) - ); - -CREATE CACHED TABLE PUBLIC.INFRA_ACTIVE_REQUESTS( - REQUEST_ID VARCHAR NOT NULL SELECTIVITY 100, - CLIENT_REQUEST_ID VARCHAR SELECTIVITY 6, - ACTION VARCHAR SELECTIVITY 1, - REQUEST_STATUS VARCHAR SELECTIVITY 1, - STATUS_MESSAGE longtext SELECTIVITY 36, - PROGRESS VARCHAR SELECTIVITY 1, - START_TIME VARCHAR, - END_TIME VARCHAR, - SOURCE VARCHAR SELECTIVITY 2, - VNF_ID VARCHAR SELECTIVITY 15, - VNF_NAME VARCHAR SELECTIVITY 11, - VNF_TYPE VARCHAR SELECTIVITY 5, - SERVICE_TYPE VARCHAR SELECTIVITY 1, - AIC_NODE_CLLI VARCHAR SELECTIVITY 1, - TENANT_ID VARCHAR SELECTIVITY 2, - PROV_STATUS VARCHAR SELECTIVITY 1, - VNF_PARAMS VARCHAR SELECTIVITY 1, - VNF_OUTPUTS VARCHAR SELECTIVITY 3, - REQUEST_BODY VARCHAR SELECTIVITY 79, - RESPONSE_BODY VARCHAR SELECTIVITY 7, - LAST_MODIFIED_BY VARCHAR SELECTIVITY 2, - MODIFY_TIME VARCHAR, - REQUEST_TYPE VARCHAR SELECTIVITY 1, - VOLUME_GROUP_ID VARCHAR SELECTIVITY 2, - VOLUME_GROUP_NAME VARCHAR SELECTIVITY 3, - VF_MODULE_ID VARCHAR SELECTIVITY 5, - VF_MODULE_NAME VARCHAR SELECTIVITY 8, - VF_MODULE_MODEL_NAME VARCHAR SELECTIVITY 3, - AAI_SERVICE_ID VARCHAR SELECTIVITY 1, - AIC_CLOUD_REGION VARCHAR SELECTIVITY 1, - CALLBACK_URL VARCHAR SELECTIVITY 1, - CORRELATOR VARCHAR SELECTIVITY 1, - NETWORK_ID VARCHAR SELECTIVITY 2, - NETWORK_NAME VARCHAR SELECTIVITY 4, - NETWORK_TYPE VARCHAR SELECTIVITY 1, - REQUEST_SCOPE VARCHAR SELECTIVITY 1, - REQUEST_ACTION VARCHAR SELECTIVITY 1, - SERVICE_INSTANCE_ID VARCHAR SELECTIVITY 34, - SERVICE_INSTANCE_NAME VARCHAR SELECTIVITY 25, - REQUESTOR_ID VARCHAR SELECTIVITY 2, - CONFIGURATION_ID VARCHAR SELECTIVITY 1, - CONFIGURATION_NAME VARCHAR SELECTIVITY 2, - OPERATIONAL_ENV_ID VARCHAR SELECTIVITY 1, - OPERATIONAL_ENV_NAME VARCHAR SELECTIVITY 1 -); - -INSERT INTO PUBLIC.INFRA_ACTIVE_REQUESTS(REQUEST_ID, CLIENT_REQUEST_ID, ACTION, REQUEST_STATUS, STATUS_MESSAGE, PROGRESS, START_TIME, END_TIME, SOURCE, VNF_ID, VNF_NAME, VNF_TYPE, SERVICE_TYPE, AIC_NODE_CLLI, TENANT_ID, PROV_STATUS, VNF_PARAMS, VNF_OUTPUTS, REQUEST_BODY, RESPONSE_BODY, LAST_MODIFIED_BY, MODIFY_TIME, REQUEST_TYPE, VOLUME_GROUP_ID, VOLUME_GROUP_NAME, VF_MODULE_ID, VF_MODULE_NAME, VF_MODULE_MODEL_NAME, AAI_SERVICE_ID, AIC_CLOUD_REGION, CALLBACK_URL, CORRELATOR, NETWORK_ID, NETWORK_NAME, NETWORK_TYPE, REQUEST_SCOPE, REQUEST_ACTION, SERVICE_INSTANCE_ID, SERVICE_INSTANCE_NAME, REQUESTOR_ID, CONFIGURATION_ID, CONFIGURATION_NAME, OPERATIONAL_ENV_ID, OPERATIONAL_ENV_NAME) VALUES -('00032ab7-3fb3-42e5-965d-8ea592502017', '00032ab7-3fb3-42e5-965d-8ea592502016', 'deleteInstance', 'COMPLETE', 'Vf Module has been deleted successfully.', '100', '2016-12-22 18:59:54', '2016-12-22 19:00:28', 'VID', 'b92f60c8-8de3-46c1-8dc1-e4390ac2b005', null, null, null, null, '6accefef3cb442ff9e644d589fb04107', null, null, null, '{"modelInfo":{"modelType":"vfModule","modelName":"vSAMP10aDEV::base::module-0"},"requestInfo":{"source":"VID"},"cloudConfiguration":{"tenantId":"6accefef3cb442ff9e644d589fb04107","lcpCloudRegionId":"mtn6"}}', null, 'BPMN', '2016-12-22 19:00:28', null, null, null, 'c7d527b1-7a91-49fd-b97d-1c8c0f4a7992', null, 'vSAMP10aDEV::base::module-0', null, 'mtn6', null, null, null, null, null, 'vfModule', 'deleteInstance', 'e3b5744d-2ad1-4cdd-8390-c999a38829bc', null, null, null, null, null, null), -('00093944-bf16-4373-ab9a-3adfe730ff2d', null, 'createInstance', 'FAILED', 'Error: Locked instance - This service (MSODEV_1707_SI_vSAMP10a_011-4) already has a request being worked with a status of IN_PROGRESS (RequestId - 278e83b1-4f9f-450e-9e7d-3700a6ed22f4). The existing request must finish or be cleaned up before proceeding.', '100', '2017-07-11 18:33:26', '2017-07-11 18:33:26', 'VID', null, null, null, null, null, '19123c2924c648eb8e42a3c1f14b7682', null, null, null, '{"modelInfo":{"modelInvariantId":"9647dfc4-2083-11e7-93ae-92361f002671","modelType":"service","modelName":"MSOTADevInfra_vSAMP10a_Service","modelVersion":"1.0","modelVersionId":"5df8b6de-2083-11e7-93ae-92361f002671"},"requestInfo":{"source":"VID","instanceName":"MSODEV_1707_SI_vSAMP10a_011-4","suppressRollback":false,"requestorId":"xxxxxx"},"subscriberInfo":{"globalSubscriberId":"MSO_1610_dev","subscriberName":"MSO_1610_dev"},"cloudConfiguration":{"tenantId":"19123c2924c648eb8e42a3c1f14b7682","lcpCloudRegionId":"mtn6"},"requestParameters":{"subscriptionServiceType":"MSO-dev-service-type","userParams":[{"name":"someUserParam","value":"someValue"}],"aLaCarte":true,"autoBuildVfModules":false,"cascadeDelete":false,"usePreload":true,"alaCarteSet":true,"alaCarte":true}}', null, 'APIH', null, null, null, null, null, null, null, null, 'mtn6', null, null, null, null, null, 'service', 'createInstance', null, 'MSODEV_1707_SI_vSAMP10a_011-4', 'xxxxxx', null, null, null, null), -('001619d2-a297-4a4b-a9f5-e2823c88458f', '001619d2-a297-4a4b-a9f5-e2823c88458f', 'CREATE_VF_MODULE', 'COMPLETE', 'COMPLETED', '100', '2016-07-01 14:11:42', '2017-05-02 16:03:34', 'PORTAL', null, 'test-vscp', 'elena_test21', null, null, '381b9ff6c75e4625b7a4182f90fc68d3', null, null, null, STRINGDECODE('<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<vnf-request xmlns=\"http://org.onap.so/mso/infra/vnf-request/v1\">\n <request-info>\n <request-id>001619d2-a297-4a4b-a9f5-e2823c88458f</request-id>\n <action>CREATE_VF_MODULE</action>\n <source>PORTAL</source>\n </request-info>\n <vnf-inputs>\n <vnf-name>test-vscp</vnf-name>\n <vf-module-name>moduleName</vf-module-name>\n <vnf-type>elena_test21</vnf-type>\n <vf-module-model-name>moduleModelName</vf-module-model-name>\n <asdc-service-model-version>1.0</asdc-service-model-version>\n <service-id>a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb</service-id>\n <aic-cloud-region>mtn9</aic-cloud-region>\n <tenant-id>381b9ff6c75e4625b7a4182f90fc68d3</tenant-id>\n <persona-model-id></persona-model-id>\n <persona-model-version></persona-model-version>\n <is-base-vf-module>false</is-base-vf-module>\n </vnf-inputs>\n <vnf-params xmlns:tns=\"http://org.onap.so/mso/infra/vnf-request/v1\"/>\n</vnf-request>\n'), 'NONE', 'RDBTEST', '2016-07-01 14:11:42', 'VNF', null, null, null, 'MODULENAME1', 'moduleModelName', 'a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb', 'mtn9', null, null, null, null, null, 'vfModule', 'createInstance', null, null, null, null, null, null, null); -INSERT INTO PUBLIC.INFRA_ACTIVE_REQUESTS(REQUEST_ID, CLIENT_REQUEST_ID, ACTION, REQUEST_STATUS, STATUS_MESSAGE, PROGRESS, START_TIME, END_TIME, SOURCE, VNF_ID, VNF_NAME, VNF_TYPE, SERVICE_TYPE, AIC_NODE_CLLI, TENANT_ID, PROV_STATUS, VNF_PARAMS, VNF_OUTPUTS, REQUEST_BODY, RESPONSE_BODY, LAST_MODIFIED_BY, MODIFY_TIME, REQUEST_TYPE, VOLUME_GROUP_ID, VOLUME_GROUP_NAME, VF_MODULE_ID, VF_MODULE_NAME, VF_MODULE_MODEL_NAME, AAI_SERVICE_ID, AIC_CLOUD_REGION, CALLBACK_URL, CORRELATOR, NETWORK_ID, NETWORK_NAME, NETWORK_TYPE, REQUEST_SCOPE, REQUEST_ACTION, SERVICE_INSTANCE_ID, SERVICE_INSTANCE_NAME, REQUESTOR_ID, CONFIGURATION_ID, CONFIGURATION_NAME, OPERATIONAL_ENV_ID, OPERATIONAL_ENV_NAME) VALUES -('00164b9e-784d-48a8-8973-bbad6ef818ed', null, 'createInstance', 'COMPLETE', 'Service Instance was created successfully.', '100', '2017-09-28 12:45:51', '2017-09-28 12:45:53', 'VID', null, null, null, null, null, '19123c2924c648eb8e42a3c1f14b7682', null, null, null, '{"modelInfo":{"modelCustomizationName":null,"modelInvariantId":"52b49b5d-3086-4ffd-b5e6-1b1e5e7e062f","modelType":"service","modelNameVersionId":null,"modelName":"MSO Test Network","modelVersion":"1.0","modelCustomizationUuid":null,"modelVersionId":"aed5a5b7-20d3-44f7-90a3-ddbd16f14d1e","modelCustomizationId":null,"modelUuid":null,"modelInvariantUuid":null,"modelInstanceName":null},"requestInfo":{"billingAccountNumber":null,"callbackUrl":null,"correlator":null,"orderNumber":null,"productFamilyId":null,"orderVersion":null,"source":"VID","instanceName":"DEV-MTN6-3100-0927-1","suppressRollback":false,"requestorId":"xxxxxx"},"relatedInstanceList":null,"subscriberInfo":{"globalSubscriberId":"MSO_1610_dev","subscriberName":"MSO_1610_dev"},"cloudConfiguration":{"aicNodeClli":null,"tenantId":"19123c2924c648eb8e42a3c1f14b7682","lcpCloudRegionId":"mtn6"},"requestParameters":{"subscriptionServiceType":"MSO-dev-service-type","userParams":[{"name":"someUserParam","value":"someValue"}],"aLaCarte":true,"autoBuildVfModules":false,"cascadeDelete":false,"usePreload":true,"alaCarte":true},"project":null,"owningEntity":null,"platform":null,"lineOfBusiness":null}', null, 'CreateGenericALaCarteServiceInstance', '2017-09-28 12:45:52', null, null, null, null, null, null, null, 'mtn6', null, null, null, null, null, 'service', 'createInstance', 'b2f59173-b7e5-4e0f-8440-232fd601b865', 'DEV-MTN6-3100-0927-1', 'md5621', null, null, null, null), -('00173cc9-5ce2-4673-a810-f87fefb2829e', null, 'createInstance', 'FAILED', 'Error parsing request. No valid instanceName is specified', '100', '2017-04-14 21:08:46', '2017-04-14 21:08:46', 'VID', null, null, null, null, null, 'a259ae7b7c3f493cb3d91f95a7c18149', null, null, null, '{"modelInfo":{"modelInvariantId":"ff6163d4-7214-459e-9f76-507b4eb00f51","modelType":"service","modelName":"ConstraintsSrvcVID","modelVersion":"2.0","modelVersionId":"722d256c-a374-4fba-a14f-a59b76bb7656"},"requestInfo":{"productFamilyId":"LRSI-OSPF","source":"VID","requestorId":"xxxxxx"},"subscriberInfo":{"globalSubscriberId":"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb"},"cloudConfiguration":{"tenantId":"a259ae7b7c3f493cb3d91f95a7c18149","lcpCloudRegionId":"mtn16"},"requestParameters":{"subscriptionServiceType":"Mobility","userParams":[{"name":"neutronport6_name","value":"8"},{"name":"neutronnet5_network_name","value":"8"},{"name":"contrailv2vlansubinterface3_name","value":"false"}]}}', null, 'APIH', null, null, null, null, null, null, null, null, 'mtn16', null, null, null, null, null, 'service', 'createInstance', null, null, null, null, null, null, null), -('0017f68c-eb2d-45bb-b7c7-ec31b37dc349', null, 'activateInstance', 'UNLOCKED', null, '20', '2017-09-26 16:09:29', null, 'VID', null, null, null, null, null, null, null, null, null, '{"modelInfo":{"modelCustomizationName":null,"modelInvariantId":"1587cf0e-f12f-478d-8530-5c55ac578c39","modelType":"configuration","modelNameVersionId":null,"modelName":null,"modelVersion":null,"modelCustomizationUuid":null,"modelVersionId":"36a3a8ea-49a6-4ac8-b06c-89a545444455","modelCustomizationId":"68dc9a92-214c-11e7-93ae-92361f002671","modelUuid":null,"modelInvariantUuid":null,"modelInstanceName":null},"requestInfo":{"billingAccountNumber":null,"callbackUrl":null,"correlator":null,"orderNumber":null,"productFamilyId":null,"orderVersion":null,"source":"VID","instanceName":null,"suppressRollback":false,"requestorId":"xxxxxx"},"relatedInstanceList":[{"relatedInstance":{"instanceName":null,"instanceId":"9e15a443-af65-4f05-9000-47ae495e937d","modelInfo":{"modelCustomizationName":null,"modelInvariantId":"de19ae10-9a25-11e7-abc4-cec278b6b50a","modelType":"service","modelNameVersionId":null,"modelName":"MSOTADevInfra_Configuration_Service","modelVersion":"1.0","modelCustomizationUuid":null,"modelVersionId":"ee938612-9a25-11e7-abc4-cec278b6b50a","modelCustomizationId":null,"modelUuid":null,"modelInvariantUuid":null,"modelInstanceName":null},"instanceDirection":null}}],"subscriberInfo":null,"cloudConfiguration":{"aicNodeClli":null,"tenantId":null,"lcpCloudRegionId":"mtn6"},"requestParameters":{"subscriptionServiceType":null,"userParams":[],"aLaCarte":false,"autoBuildVfModules":false,"cascadeDelete":false,"usePreload":true,"alaCarte":false},"project":null,"owningEntity":null,"platform":null,"lineOfBusiness":null}', null, 'APIH', '2017-09-26 16:09:29', null, null, null, null, null, null, null, 'mtn6', null, null, null, null, null, 'configuration', 'activateInstance', '9e15a443-af65-4f05-9000-47ae495e937d', null, 'xxxxxx', '26ef7f15-57bb-48df-8170-e59edc26234c', null, null, null); - -CREATE CACHED TABLE PUBLIC.ARCHIVED_INFRA_REQUESTS( - REQUEST_ID VARCHAR NOT NULL SELECTIVITY 100, - CLIENT_REQUEST_ID VARCHAR SELECTIVITY 6, - ACTION VARCHAR SELECTIVITY 1, - REQUEST_STATUS VARCHAR SELECTIVITY 1, - STATUS_MESSAGE longtext SELECTIVITY 36, - PROGRESS VARCHAR SELECTIVITY 1, - START_TIME VARCHAR, - END_TIME VARCHAR, - SOURCE VARCHAR SELECTIVITY 2, - VNF_ID VARCHAR SELECTIVITY 15, - VNF_NAME VARCHAR SELECTIVITY 11, - VNF_TYPE VARCHAR SELECTIVITY 5, - SERVICE_TYPE VARCHAR SELECTIVITY 1, - AIC_NODE_CLLI VARCHAR SELECTIVITY 1, - TENANT_ID VARCHAR SELECTIVITY 2, - PROV_STATUS VARCHAR SELECTIVITY 1, - VNF_PARAMS VARCHAR SELECTIVITY 1, - VNF_OUTPUTS VARCHAR SELECTIVITY 3, - REQUEST_BODY VARCHAR SELECTIVITY 79, - RESPONSE_BODY VARCHAR SELECTIVITY 7, - LAST_MODIFIED_BY VARCHAR SELECTIVITY 2, - MODIFY_TIME VARCHAR, - REQUEST_TYPE VARCHAR SELECTIVITY 1, - VOLUME_GROUP_ID VARCHAR SELECTIVITY 2, - VOLUME_GROUP_NAME VARCHAR SELECTIVITY 3, - VF_MODULE_ID VARCHAR SELECTIVITY 5, - VF_MODULE_NAME VARCHAR SELECTIVITY 8, - VF_MODULE_MODEL_NAME VARCHAR SELECTIVITY 3, - AAI_SERVICE_ID VARCHAR SELECTIVITY 1, - AIC_CLOUD_REGION VARCHAR SELECTIVITY 1, - CALLBACK_URL VARCHAR SELECTIVITY 1, - CORRELATOR VARCHAR SELECTIVITY 1, - NETWORK_ID VARCHAR SELECTIVITY 2, - NETWORK_NAME VARCHAR SELECTIVITY 4, - NETWORK_TYPE VARCHAR SELECTIVITY 1, - REQUEST_SCOPE VARCHAR SELECTIVITY 1, - REQUEST_ACTION VARCHAR SELECTIVITY 1, - SERVICE_INSTANCE_ID VARCHAR SELECTIVITY 34, - SERVICE_INSTANCE_NAME VARCHAR SELECTIVITY 25, - REQUESTOR_ID VARCHAR SELECTIVITY 2, - CONFIGURATION_ID VARCHAR SELECTIVITY 1, - CONFIGURATION_NAME VARCHAR SELECTIVITY 2, - OPERATIONAL_ENV_ID VARCHAR SELECTIVITY 1, - OPERATIONAL_ENV_NAME VARCHAR SELECTIVITY 1 -); - -CREATE CACHED TABLE PUBLIC.SITE_STATUS( - SITE_NAME VARCHAR NOT NULL, - STATUS VARCHAR, - CREATION_TIMESTAMP VARCHAR -); - -INSERT INTO PUBLIC.SITE_STATUS(SITE_NAME, STATUS, CREATION_TIMESTAMP) VALUES -('testSite', '0', '2017-11-30 15:48:09'), -('test name', null, null), -('test name2', '1', null), -('test name3', '1', null), -('test name4', '1', '2017-11-30 15:48:09'), -('test name update', '0', null); - -CREATE CACHED TABLE PUBLIC.WATCHDOG_DISTRIBUTIONID_STATUS( - DISTRIBUTION_ID VARCHAR NOT NULL, - DISTRIBUTION_ID_STATUS VARCHAR, - CREATE_TIME VARCHAR, - MODIFY_TIME VARCHAR -); - - -INSERT INTO PUBLIC.WATCHDOG_DISTRIBUTIONID_STATUS(DISTRIBUTION_ID, DISTRIBUTION_ID_STATUS, CREATE_TIME, MODIFY_TIME) VALUES -('1533c4bd-a3e3-493f-a16d-28c20614415e', '', '2017-11-30 15:48:09', '2017-11-30 15:48:09'), -('55429711-809b-4a3b-9ee5-5120d46d9de0', '', '2017-11-30 16:35:36', '2017-11-30 16:35:36'), -('67f0b2d1-9013-4b2b-9914-bbe2288284fb', '', '2017-11-30 15:54:39', '2017-11-30 15:54:39'); - -CREATE CACHED TABLE PUBLIC.WATCHDOG_PER_COMPONENT_DISTRIBUTION_STATUS( - DISTRIBUTION_ID VARCHAR NOT NULL, - COMPONENT_NAME VARCHAR NOT NULL, - COMPONENT_DISTRIBUTION_STATUS VARCHAR, - CREATE_TIME VARCHAR, - MODIFY_TIME VARCHAR -); - - -INSERT INTO PUBLIC.WATCHDOG_PER_COMPONENT_DISTRIBUTION_STATUS(DISTRIBUTION_ID, COMPONENT_NAME, COMPONENT_DISTRIBUTION_STATUS, CREATE_TIME, MODIFY_TIME) VALUES -('1533c4bd-a3e3-493f-a16d-28c20614415e', 'MSO', 'COMPONENT_DONE_OK', '2017-11-30 15:48:09', '2017-11-30 15:48:09'), -('55429711-809b-4a3b-9ee5-5120d46d9de0', 'MSO', 'COMPONENT_DONE_ERROR', '2017-11-30 16:35:36', '2017-11-30 16:35:36'), -('67f0b2d1-9013-4b2b-9914-bbe2288284fb', 'MSO', 'COMPONENT_DONE_OK', '2017-11-30 15:54:39', '2017-11-30 15:54:39'); - -CREATE CACHED TABLE PUBLIC.WATCHDOG_SERVICE_MOD_VER_ID_LOOKUP( - DISTRIBUTION_ID VARCHAR NOT NULL, - SERVICE_MODEL_VERSION_ID VARCHAR NOT NULL, - CREATE_TIME VARCHAR, - MODIFY_TIME VARCHAR -); - - -INSERT INTO PUBLIC.WATCHDOG_SERVICE_MOD_VER_ID_LOOKUP(DISTRIBUTION_ID, SERVICE_MODEL_VERSION_ID, CREATE_TIME, MODIFY_TIME) VALUES -('1533c4bd-a3e3-493f-a16d-28c20614415e', '7e813ab5-88d3-4fcb-86c0-498c5d7eef9a', '2017-11-30 15:48:08', '2017-11-30 15:48:08'), -('55429711-809b-4a3b-9ee5-5120d46d9de0', 'cc031e75-4442-4d1a-b774-8a2b434e0a50', '2017-11-30 16:35:36', '2017-11-30 16:35:36'), -('67f0b2d1-9013-4b2b-9914-bbe2288284fb', 'eade1e9d-c1ec-4ef3-bc31-60570fba1573', '2017-11-30 15:54:39', '2017-11-30 15:54:39'); - -ALTER TABLE PUBLIC.INFRA_ACTIVE_REQUESTS ADD CONSTRAINT PUBLIC.CONSTRAINT_E PRIMARY KEY(REQUEST_ID); -ALTER TABLE PUBLIC.SITE_STATUS ADD CONSTRAINT PUBLIC.CONSTRAINT_C PRIMARY KEY(SITE_NAME); -ALTER TABLE PUBLIC.WATCHDOG_DISTRIBUTIONID_STATUS ADD CONSTRAINT PUBLIC.CONSTRAINT_7 PRIMARY KEY(DISTRIBUTION_ID); -ALTER TABLE PUBLIC.WATCHDOG_PER_COMPONENT_DISTRIBUTION_STATUS ADD CONSTRAINT PUBLIC.CONSTRAINT_D PRIMARY KEY(DISTRIBUTION_ID, COMPONENT_NAME); -ALTER TABLE PUBLIC.WATCHDOG_SERVICE_MOD_VER_ID_LOOKUP ADD CONSTRAINT PUBLIC.CONSTRAINT_6 PRIMARY KEY(DISTRIBUTION_ID, SERVICE_MODEL_VERSION_ID); -ALTER TABLE PUBLIC.WATCHDOG_PER_COMPONENT_DISTRIBUTION_STATUS ADD CONSTRAINT PUBLIC.CONSTRAINT_DE FOREIGN KEY(DISTRIBUTION_ID) REFERENCES PUBLIC.WATCHDOG_DISTRIBUTIONID_STATUS(DISTRIBUTION_ID) NOCHECK; - - |