summaryrefslogtreecommitdiffstats
path: root/mso-api-handlers/mso-requests-db/src
diff options
context:
space:
mode:
Diffstat (limited to 'mso-api-handlers/mso-requests-db/src')
-rw-r--r--mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraActiveRequests.java101
-rw-r--r--mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraRequests.java962
-rw-r--r--mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryCustom.java33
-rw-r--r--mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImpl.java884
-rw-r--r--mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/QueryOperationType.java69
-rw-r--r--mso-api-handlers/mso-requests-db/src/test/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImplTest.java184
6 files changed, 1270 insertions, 963 deletions
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..0833064f8a 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
@@ -42,515 +42,515 @@ 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/data/repository/InfraActiveRequestsRepositoryCustom.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryCustom.java
index ba237bfa35..570861dfa1 100644
--- 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
@@ -30,28 +30,31 @@ import org.springframework.stereotype.Repository;
@Repository
public interface InfraActiveRequestsRepositoryCustom {
- public boolean healthCheck();
+ public boolean healthCheck();
- public InfraActiveRequests getRequestFromInfraActive(String requestId);
+ public InfraActiveRequests getRequestFromInfraActive(String requestId);
- public InfraActiveRequests checkInstanceNameDuplicate(HashMap<String, String> instanceIdMap, String instanceName,
- String requestScope);
+ public InfraActiveRequests checkInstanceNameDuplicate(HashMap<String, String> instanceIdMap, String instanceName,
+ String requestScope);
- public List<InfraActiveRequests> getOrchestrationFiltersFromInfraActive(Map<String, List<String>> orchestrationMap);
+ 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);
+ // 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 List<InfraActiveRequests> getRequestListFromInfraActive(String queryAttributeName, String queryValue,
+ String requestType);
- public InfraActiveRequests getRequestFromInfraActive(String requestId, String requestType);
+ public InfraActiveRequests getRequestFromInfraActive(String requestId, String requestType);
- public InfraActiveRequests checkDuplicateByVnfName(String vnfName, String action, String requestType);
+ public InfraActiveRequests checkDuplicateByVnfName(String vnfName, String action, String requestType);
- public InfraActiveRequests checkDuplicateByVnfId(String vnfId, String action, String requestType);
+ public InfraActiveRequests checkDuplicateByVnfId(String vnfId, String action, String requestType);
+
+ public InfraActiveRequests checkVnfIdStatus(String operationalEnvironmentId);
+
+ List<InfraActiveRequests> getInfraActiveRequests(final Map<String, String[]> filters, final long startTime,
+ final long endTime, final Integer maxResult);
- 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
index 3240972a58..d66e378146 100644
--- 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
@@ -25,11 +25,13 @@ import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.concurrent.TimeUnit;
import javax.persistence.EntityManager;
@@ -43,13 +45,9 @@ 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;
@@ -58,509 +56,563 @@ import org.springframework.transaction.annotation.Transactional;
@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()
- */
+ @Qualifier("requestEntityManagerFactory")
+ @Autowired
+ private EntityManager entityManager;
+
+ protected static MsoLogger msoLogger =
+ MsoLogger.getMsoLogger(MsoLogger.Catalog.GENERAL, InfraActiveRequestsRepositoryImpl.class);
+
+ protected static final String REQUEST_STATUS = "requestStatus";
+ protected static final String SOURCE = "source";
+ protected static final String START_TIME = "startTime";
+ protected static final String END_TIME = "endTime";
+ 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";
+ protected static final String ACTION = "action";
+
+ private static final List<String> VALID_COLUMNS =
+ Arrays.asList(REQUEST_ID, SERVICE_INSTANCE_ID, SERVICE_INSTANCE_NAME, ACTION, REQUEST_STATUS);
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.so.requestsdb.InfraActiveRequestsRepositoryCustom#healthCheck()
+ */
@Override
- public boolean healthCheck () {
-
- Query query = entityManager.createNativeQuery(" show tables ");
+ public boolean healthCheck() {
+
+ final Query query = entityManager.createNativeQuery(" show tables ");
- List<?> list = query.getResultList();
+ final List<?> list = query.getResultList();
return true;
}
- private List<InfraActiveRequests> executeInfraQuery (CriteriaQuery<InfraActiveRequests> crit, List <Predicate> predicates, Order order) {
+ private List<InfraActiveRequests> executeInfraQuery(final CriteriaQuery<InfraActiveRequests> crit,
+ final List<Predicate> predicates, final Order order) {
+
+ final long startTime = System.currentTimeMillis();
+ msoLogger.debug("Execute query on infra active request table");
- long startTime = System.currentTimeMillis ();
- msoLogger.debug ("Execute query on infra active request table");
-
- List <InfraActiveRequests> results = new ArrayList<InfraActiveRequests>();
+ List<InfraActiveRequests> results = new ArrayList<InfraActiveRequests>();
try {
- CriteriaBuilder cb = entityManager.getCriteriaBuilder();
- crit.where(cb.and(predicates.toArray(new Predicate[0])));
+ final 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);
+ 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)
- */
+
+ /*
+ * (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");
+ public InfraActiveRequests getRequestFromInfraActive(final String requestId) {
+ final 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);
+ final 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);
+
+ 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)
- */
+
+ /*
+ * (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));
- }
-
+ public InfraActiveRequests checkInstanceNameDuplicate(final HashMap<String, String> instanceIdMap,
+ final String instanceName, final String requestScope) {
+
+ final List<Predicate> predicates = new LinkedList<>();
+ final CriteriaBuilder cb = entityManager.getCriteriaBuilder();
+ final CriteriaQuery<InfraActiveRequests> crit = cb.createQuery(InfraActiveRequests.class);
+ final 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")));
- }
+ 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);
-
+
+ predicates.add(tableRoot.get(REQUEST_STATUS)
+ .in(Arrays.asList("PENDING", "IN_PROGRESS", "TIMEOUT", "PENDING_MANUAL_TASK")));
+
+ final Order order = cb.desc(tableRoot.get(START_TIME));
+
+ final List<InfraActiveRequests> dupList = executeInfraQuery(crit, predicates, order);
+
InfraActiveRequests infraActiveRequests = null;
-
- if(dupList != null && !dupList.isEmpty()){
- infraActiveRequests = dupList.get(0);
+
+ if (dupList != null && !dupList.isEmpty()) {
+ infraActiveRequests = dupList.get(0);
}
-
- return infraActiveRequests;
+
+ return infraActiveRequests;
}
-
- /* (non-Javadoc)
- * @see org.onap.so.requestsdb.InfraActiveRequestsRepositoryCustom#getOrchestrationFiltersFromInfraActive(java.util.Map)
- */
+
+ /*
+ * (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);
+ public List<InfraActiveRequests> getOrchestrationFiltersFromInfraActive(
+ final Map<String, List<String>> orchestrationMap) {
+
+
+ final List<Predicate> predicates = new LinkedList<>();
+ final CriteriaBuilder cb = entityManager.getCriteriaBuilder();
+ final CriteriaQuery<InfraActiveRequests> crit = cb.createQuery(InfraActiveRequests.class);
+ final Root<InfraActiveRequests> tableRoot = crit.from(InfraActiveRequests.class);
+ for (final 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";
+ }
+
+ final String propertyValue = entry.getValue().get(1);
+ if ("startTime".equals(mapKey)) {
+ final SimpleDateFormat format = new SimpleDateFormat("MM-dd-yyyy");
+ try {
+ final Date thisDate = format.parse(propertyValue);
+ final Timestamp minTime = new Timestamp(thisDate.getTime());
+ final 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 (final 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));
+ }
+
+ }
+
+ final 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
+ // 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)
- */
+ /*
+ * (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);
+ public List<InfraActiveRequests> getCloudOrchestrationFiltersFromInfraActive(
+ final Map<String, String> orchestrationMap) {
+ final List<Predicate> predicates = new LinkedList<>();
+ final CriteriaBuilder cb = entityManager.getCriteriaBuilder();
+ final CriteriaQuery<InfraActiveRequests> crit = cb.createQuery(InfraActiveRequests.class);
+ final 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
+ final String resourceType = orchestrationMap.get("resourceType");
+ if (resourceType == null) {
+ predicates.add(cb.equal(tableRoot.get("requestScope"), "operationalEnvironment"));
+ }
+
+ for (final 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";
+ }
+
+ final String propertyValue = entry.getValue();
+ if (mapKey.equals("startTime")) {
+ final SimpleDateFormat format = new SimpleDateFormat("MM-dd-yyyy");
+ try {
+ final Date thisDate = format.parse(propertyValue);
+ final Timestamp minTime = new Timestamp(thisDate.getTime());
+ final Timestamp maxTime = new Timestamp(thisDate.getTime() + TimeUnit.DAYS.toMillis(1));
+
+ predicates.add(cb.between(tableRoot.get(mapKey), minTime, maxTime));
+ } catch (final Exception e) {
+ msoLogger.debug("Exception in getCloudOrchestrationFiltersFromInfraActive(): + " + e.getMessage());
+ return null;
+ }
+ } else {
+ predicates.add(cb.equal(tableRoot.get(mapKey), propertyValue));
+ }
+ }
+
+ final 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)
- */
+ /*
+ * (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);
+ public List<InfraActiveRequests> getRequestListFromInfraActive(final String queryAttributeName,
+ final String queryValue, final 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 ()) {
+ final CriteriaBuilder cb = entityManager.getCriteriaBuilder();
+ final CriteriaQuery<InfraActiveRequests> crit = cb.createQuery(InfraActiveRequests.class);
+ final Root<InfraActiveRequests> candidateRoot = crit.from(InfraActiveRequests.class);
+ final Predicate isEqual = cb.equal(candidateRoot.get(queryAttributeName), queryValue);
+ final Predicate equalRequestType = cb.equal(candidateRoot.get(REQUEST_TYPE), requestType);
+ final Predicate isNull = cb.isNull(candidateRoot.get(REQUEST_TYPE));
+ final Predicate orClause = cb.or(equalRequestType, isNull);
+ final Order orderDesc = cb.desc(candidateRoot.get(START_TIME));
+ final Order orderAsc = cb.asc(candidateRoot.get(SOURCE));
+ crit.where(cb.and(isEqual, orClause)).orderBy(orderDesc, orderAsc);
+
+ final 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);
+ } catch (final Exception exception) {
+ msoLogger.error("Unable to execute query", exception);
}
- return null;
+ return Collections.emptyList();
}
- /* (non-Javadoc)
- * @see org.onap.so.requestsdb.InfraActiveRequestsRepositoryCustom#getRequestFromInfraActive(java.lang.String, java.lang.String)
- */
+ /*
+ * (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);
+ public InfraActiveRequests getRequestFromInfraActive(final String requestId, final String requestType) {
+ final 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);
+ final 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);
+ 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)
- */
+
+ /*
+ * (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) {
+ public InfraActiveRequests checkDuplicateByVnfName(final String vnfName, final String action,
+ final String requestType) {
- long startTime = System.currentTimeMillis ();
- msoLogger.debug ("Get infra request from DB for VNF " + vnfName + " and action " + action + " and requestType " + requestType);
+ final 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);
+ final 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);
+ final 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);
+ 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)
- */
+ /*
+ * (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) {
+ public InfraActiveRequests checkDuplicateByVnfId(final String vnfId, final String action,
+ final String requestType) {
- long startTime = System.currentTimeMillis ();
- msoLogger.debug ("Get list of infra requests from DB for VNF " + vnfId + " and action " + action);
+ final 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);
+ final 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);
+ final 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);
+ 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>
+
+ /*
+ * (non-Javadoc)
*
- * @param operStatus the resource operation status
- * @since ONAP Amsterdam Release
+ * @see
+ * org.onap.so.requestsdb.InfraActiveRequestsRepositoryCustom#checkVnfIdStatus(java.lang.String)
*/
- 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());
+ @Override
+ public InfraActiveRequests checkVnfIdStatus(final String operationalEnvironmentId) {
+ final long startTime = System.currentTimeMillis();
+ msoLogger.debug("Get Infra request from DB for OperationalEnvironmentId " + operationalEnvironmentId);
+
+ InfraActiveRequests ar = null;
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;
- }
+ final CriteriaBuilder cb = entityManager.getCriteriaBuilder();
+ final CriteriaQuery<InfraActiveRequests> crit = cb.createQuery(InfraActiveRequests.class);
+ final Root<InfraActiveRequests> candidateRoot = crit.from(InfraActiveRequests.class);
+ final Predicate operationalEnvEq =
+ cb.equal(candidateRoot.get("operationalEnvId"), operationalEnvironmentId);
+ final Predicate requestStatusNotEq = cb.notEqual(candidateRoot.get(REQUEST_STATUS), "COMPLETE");
+ final Predicate actionEq = cb.equal(candidateRoot.get("action"), "create");
+ final Order startTimeOrder = cb.desc(candidateRoot.get("startTime"));
+ crit.select(candidateRoot);
+ crit.where(cb.and(operationalEnvEq, requestStatusNotEq, actionEq));
+ crit.orderBy(startTimeOrder);
+ final TypedQuery<InfraActiveRequests> query = entityManager.createQuery(crit);
+ final List<InfraActiveRequests> results = query.getResultList();
+ if (!results.isEmpty()) {
+ ar = results.get(0);
}
-
- 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);
+ "Successfully", "RequestDB", "checkDuplicateByVnfName", null);
+ }
+
+ return ar;
+ }
+
+ protected <T> T getSingleResult(final Query query) {
+ query.setMaxResults(1);
+ final 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();
+ }
+
+ }
+
+ @Override
+ public List<InfraActiveRequests> getInfraActiveRequests(final Map<String, String[]> filters, final long startTime,
+ final long endTime, final Integer maxResult) {
+ if (filters == null) {
+ return Collections.emptyList();
+ }
+ try {
+ final CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
+ final CriteriaQuery<InfraActiveRequests> criteriaQuery =
+ criteriaBuilder.createQuery(InfraActiveRequests.class);
+ final Root<InfraActiveRequests> tableRoot = criteriaQuery.from(InfraActiveRequests.class);
+ final List<Predicate> predicates = getPredicates(filters, criteriaBuilder, tableRoot);
+
+ final Timestamp minTime = new Timestamp(startTime);
+ final Timestamp maxTime = new Timestamp(endTime);
+ predicates.add(criteriaBuilder.greaterThanOrEqualTo(tableRoot.get(START_TIME), minTime));
+ predicates.add(criteriaBuilder.lessThanOrEqualTo(tableRoot.get(END_TIME), maxTime));
+
+ criteriaQuery.where(criteriaBuilder.and(predicates.toArray(new Predicate[predicates.size()])));
+ if (maxResult != null) {
+ return entityManager.createQuery(criteriaQuery).setMaxResults(maxResult).getResultList();
+ }
+ return entityManager.createQuery(criteriaQuery).getResultList();
+ } catch (final Exception exception) {
+ msoLogger.error("Unable to execute query using filters: " + filters, exception);
+ return Collections.emptyList();
}
}
- /* (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();
- }
-
- }
+ private List<Predicate> getPredicates(final Map<String, String[]> filters, final CriteriaBuilder criteriaBuilder,
+ final Root<InfraActiveRequests> tableRoot) {
+ final List<Predicate> predicates = new LinkedList<>();
+ for (final Entry<String, String[]> entry : filters.entrySet()) {
+ final String[] params = entry.getValue();
+ if (VALID_COLUMNS.contains(entry.getKey()) && params.length == 2) {
+ final QueryOperationType operationType = QueryOperationType.getQueryOperationType(params[0]);
+ final Predicate predicate =
+ operationType.getPredicate(criteriaBuilder, tableRoot, entry.getKey(), params[1]);
+ predicates.add(predicate);
+ }
+ }
+ return predicates;
+ }
}
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/test/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImplTest.java b/mso-api-handlers/mso-requests-db/src/test/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImplTest.java
new file mode 100644
index 0000000000..d889a15fc4
--- /dev/null
+++ b/mso-api-handlers/mso-requests-db/src/test/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImplTest.java
@@ -0,0 +1,184 @@
+/*-
+ * ============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 static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertTrue;
+import static org.onap.so.db.request.data.repository.InfraActiveRequestsRepositoryImpl.ACTION;
+import static org.onap.so.db.request.data.repository.InfraActiveRequestsRepositoryImpl.REQUEST_ID;
+import static org.onap.so.db.request.data.repository.InfraActiveRequestsRepositoryImpl.SERVICE_INSTANCE_ID;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.so.TestApplication;
+import org.onap.so.db.request.beans.InfraActiveRequests;
+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 InfraActiveRequestsRepositoryImplTest {
+
+ private static final int MAX_LIMIT = 1;
+ private static final long END_TIME_IN_MILISEC = 1482436800000l;
+ private static final long START_TIME_IN_MILISEC = 1482429600000l;
+ private static final String REQUEST_ID_VALUE = "00032ab7-3fb3-42e5-965d-8ea592502017";
+ private static final String SERVICE_INSTANCE_ID_VALUE = "e3b5744d-2ad1-4cdd-8390-c999a38829bc";
+
+ @Autowired
+ private InfraActiveRequestsRepository objUnderTest;
+
+ @Test
+ public void test_GetInfraActiveRequests_emptyFiltersMap() {
+ final List<InfraActiveRequests> actualRequests = objUnderTest.getInfraActiveRequests(Collections.emptyMap(),
+ START_TIME_IN_MILISEC, END_TIME_IN_MILISEC, null);
+ assertFalse(actualRequests.isEmpty());
+ }
+
+ @Test
+ public void test_GetInfraActiveRequests_invalidFiltersMap() {
+ final Map<String, String[]> filters = new HashMap<>();
+ filters.put("OverTheMoon", new String[] {"Humpty Dumpty Sat On The Wall"});
+ final long startTime = START_TIME_IN_MILISEC - TimeUnit.DAYS.toMillis(20);
+ final long endTime = END_TIME_IN_MILISEC - TimeUnit.DAYS.toMillis(20);
+ final List<InfraActiveRequests> actualRequests =
+ objUnderTest.getInfraActiveRequests(filters, startTime, endTime, null);
+ assertTrue(actualRequests.isEmpty());
+ }
+
+ @Test
+ public void test_GetInfraActiveRequests_invalidFiltersMapWithInvalidKey() {
+ final Map<String, String[]> filters = new HashMap<>();
+ filters.put("OverTheMoon", new String[] {"Avengers", "Humpty Dumpty Sat On The Wall"});
+ final List<InfraActiveRequests> actualRequests =
+ objUnderTest.getInfraActiveRequests(filters, START_TIME_IN_MILISEC, END_TIME_IN_MILISEC, null);
+ assertFalse(actualRequests.isEmpty());
+ }
+
+ @Test
+ public void test_GetInfraActiveRequestsData_withEqualServiceInstanceId() {
+ final Map<String, String[]> values = new HashMap<>();
+ values.put(SERVICE_INSTANCE_ID, new String[] {QueryOperationType.EQ.name(), SERVICE_INSTANCE_ID_VALUE});
+ final List<InfraActiveRequests> actualRequests =
+ objUnderTest.getInfraActiveRequests(values, START_TIME_IN_MILISEC, END_TIME_IN_MILISEC, 1);
+ assertFalse(actualRequests.isEmpty());
+
+ assertEquals(SERVICE_INSTANCE_ID_VALUE, actualRequests.get(0).getServiceInstanceId());
+ }
+
+
+ @Test
+ public void test_GetInfraActiveRequestsData_withLikeRequestID() {
+ final Map<String, String[]> values = new HashMap<>();
+ values.put(REQUEST_ID, new String[] {QueryOperationType.LIKE.name(), "00032ab7"});
+ final List<InfraActiveRequests> actualRequests =
+ objUnderTest.getInfraActiveRequests(values, START_TIME_IN_MILISEC, END_TIME_IN_MILISEC, 1);
+ assertFalse(actualRequests.isEmpty());
+
+ assertEquals(REQUEST_ID_VALUE, actualRequests.get(0).getRequestId());
+ assertEquals(SERVICE_INSTANCE_ID_VALUE, actualRequests.get(0).getServiceInstanceId());
+ }
+
+
+ @Test
+ public void test_GetInfraActiveRequestsData_withLikeRequestIDAndEqualToServiceInstanceId() {
+ final Map<String, String[]> values = new HashMap<>();
+ values.put(REQUEST_ID, new String[] {QueryOperationType.LIKE.name(), "00032ab7"});
+ values.put(SERVICE_INSTANCE_ID, new String[] {QueryOperationType.EQ.name(), SERVICE_INSTANCE_ID_VALUE});
+ final List<InfraActiveRequests> actualRequests =
+ objUnderTest.getInfraActiveRequests(values, START_TIME_IN_MILISEC, END_TIME_IN_MILISEC, 1);
+ assertFalse(actualRequests.isEmpty());
+
+ assertEquals(REQUEST_ID_VALUE, actualRequests.get(0).getRequestId());
+ assertEquals(SERVICE_INSTANCE_ID_VALUE, actualRequests.get(0).getServiceInstanceId());
+ }
+
+
+ @Test
+ public void test_GetInfraActiveRequestsData_withNotEqualAction() {
+ final Map<String, String[]> values = new HashMap<>();
+ values.put(ACTION, new String[] {QueryOperationType.NEQ.name(), "createInstance"});
+ final List<InfraActiveRequests> actualRequests =
+ objUnderTest.getInfraActiveRequests(values, START_TIME_IN_MILISEC, END_TIME_IN_MILISEC, null);
+ assertFalse(actualRequests.isEmpty());
+ for (final InfraActiveRequests actualActiveRequests : actualRequests) {
+ assertNotEquals("createInstance", actualActiveRequests.getAction());
+ }
+ }
+
+
+ @Test
+ public void test_GetInfraActiveRequestsData_withNotEqualToServiceInstanceNameAndServiceInstanceIdNul() {
+ final Map<String, String[]> values = new HashMap<>();
+ values.put(ACTION, new String[] {QueryOperationType.NEQ.name(), "createInstance"});
+ values.put(SERVICE_INSTANCE_ID, new String[] {QueryOperationType.EQ.name(), SERVICE_INSTANCE_ID_VALUE});
+
+ final List<InfraActiveRequests> actualRequests =
+ objUnderTest.getInfraActiveRequests(values, START_TIME_IN_MILISEC, END_TIME_IN_MILISEC, null);
+ assertFalse(actualRequests.isEmpty());
+ for (final InfraActiveRequests actualActiveRequests : actualRequests) {
+ assertNotEquals("createInstance", actualActiveRequests.getAction());
+ assertEquals(SERVICE_INSTANCE_ID_VALUE, actualActiveRequests.getServiceInstanceId());
+ }
+ }
+
+ @Test
+ public void test_GetInfraActiveRequestsData_withStartEndDateTimeNotEqualAction() {
+ final Map<String, String[]> values = new HashMap<>();
+ values.put(ACTION, new String[] {QueryOperationType.NEQ.name(), "createInstance"});
+ final List<InfraActiveRequests> actualRequests =
+ objUnderTest.getInfraActiveRequests(values, START_TIME_IN_MILISEC, END_TIME_IN_MILISEC, null);
+ assertFalse(actualRequests.isEmpty());
+ for (final InfraActiveRequests actualActiveRequests : actualRequests) {
+ assertNotEquals("createInstance", actualActiveRequests.getAction());
+ }
+ }
+
+ @Test
+ public void test_GetInfraActiveRequestsData_withLimitNotEqualAction() {
+ final Map<String, String[]> values = new HashMap<>();
+ values.put(ACTION, new String[] {QueryOperationType.NEQ.name(), "createInstance"});
+ final List<InfraActiveRequests> actualRequests =
+ objUnderTest.getInfraActiveRequests(values, START_TIME_IN_MILISEC, END_TIME_IN_MILISEC, MAX_LIMIT);
+ assertFalse(actualRequests.isEmpty());
+ for (final InfraActiveRequests actualActiveRequests : actualRequests) {
+ assertNotEquals("createInstance", actualActiveRequests.getAction());
+ }
+ }
+
+ @Test
+ public void test_GetInfraActiveRequestsData_withNullFilters() {
+ final List<InfraActiveRequests> actualRequests =
+ objUnderTest.getInfraActiveRequests(null, START_TIME_IN_MILISEC, END_TIME_IN_MILISEC, MAX_LIMIT);
+ assertTrue(actualRequests.isEmpty());
+ }
+}