diff options
author | Kavitha P <pkavitha@aarnanetworks.com> | 2021-08-25 16:12:18 +0530 |
---|---|---|
committer | KAPIL SINGAL <ks220y@att.com> | 2021-08-27 16:58:22 +0000 |
commit | 35481027b3fdf251a3b520ab5b1ae89c7d2d0e34 (patch) | |
tree | 8fe9d3fe117005d54b31e1a136ad334e419268e4 /ms/blueprintsprocessor/functions/blueprint-audit-status/src/main | |
parent | 6b6f2360e4e60d681a5ba0fc05477f9ac9bea051 (diff) |
CCSDK-3434 CBA workflow status store
Change-Id: Iaeac6fa534c569bbc152e6c8a78c2dd23b6c4b1a
Signed-off-by: Kavitha P <pkavitha@aarnanetworks.com>
Issue-ID: CCSDK-3434
Diffstat (limited to 'ms/blueprintsprocessor/functions/blueprint-audit-status/src/main')
6 files changed, 700 insertions, 0 deletions
diff --git a/ms/blueprintsprocessor/functions/blueprint-audit-status/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/workflow/audit/DatabaseStoreAuditConstants.kt b/ms/blueprintsprocessor/functions/blueprint-audit-status/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/workflow/audit/DatabaseStoreAuditConstants.kt new file mode 100644 index 000000000..1ca8d1b30 --- /dev/null +++ b/ms/blueprintsprocessor/functions/blueprint-audit-status/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/workflow/audit/DatabaseStoreAuditConstants.kt @@ -0,0 +1,27 @@ +/* + * Copyright © 2021 Aarna Networks, Inc. + * 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. + */ + +package org.onap.ccsdk.cds.blueprintsprocessor.functions.workflow.audit + +/** + * Contants file + */ +object DatabaseStoreAuditConstants { + + const val WORKFLOW_STATUS_INPROGRESS = "In Progress" + const val WORKFLOW_STATUS_COMPLETED = "Completed" + const val WORKFLOW_STATUS_UPDATEDBY = "CBA" +} diff --git a/ms/blueprintsprocessor/functions/blueprint-audit-status/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/workflow/audit/DatabaseStoreAuditService.kt b/ms/blueprintsprocessor/functions/blueprint-audit-status/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/workflow/audit/DatabaseStoreAuditService.kt new file mode 100644 index 000000000..ecfb269f0 --- /dev/null +++ b/ms/blueprintsprocessor/functions/blueprint-audit-status/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/workflow/audit/DatabaseStoreAuditService.kt @@ -0,0 +1,243 @@ +/* + * Copyright © 2021 Aarna Networks, Inc. + * 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. + */ + +package org.onap.ccsdk.cds.blueprintsprocessor.functions.workflow.audit + +import com.fasterxml.jackson.databind.ObjectMapper +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.withContext +import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput +import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceOutput +import org.onap.ccsdk.cds.blueprintsprocessor.functions.workflow.audit.db.BlueprintAuditStatusRepository +import org.onap.ccsdk.cds.blueprintsprocessor.functions.workflow.audit.db.BlueprintWorkflowAuditStatus +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException +import org.onap.ccsdk.cds.controllerblueprints.core.utils.controllerDate +import org.slf4j.LoggerFactory +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty +import org.springframework.dao.DataIntegrityViolationException +import org.springframework.stereotype.Service +import java.util.Date + +/** + * Workflow request and response details are persisted to database + */ +@ConditionalOnProperty( + name = ["blueprintsprocessor.workflow.self-service-api.audit.storeEnable"], + havingValue = "true" +) +@Service +class DatabaseStoreAuditService( + private val blueprintAuditStatusRepository: BlueprintAuditStatusRepository +) : StoreAuditService { + + private val log = + LoggerFactory.getLogger(DatabaseStoreAuditService::class.toString()) + + /** + * store the blueprint workflow input details to database + * @param executionServiceInput {@link ExecutionServiceInput} + * @throws {@link BluePrintException} + */ + override suspend fun storeExecutionInput( + executionServiceInput: ExecutionServiceInput + ): Long { + log.info( + "storeExecutionInput called to store the Workflow action " + + "input details " + ) + var storedAuditStatus: BlueprintWorkflowAuditStatus = BlueprintWorkflowAuditStatus() + + storedAuditStatus = write( + 0, executionServiceInput.commonHeader.originatorId, + executionServiceInput.commonHeader.requestId, + executionServiceInput.commonHeader.subRequestId, + executionServiceInput.actionIdentifiers.actionName, + executionServiceInput.actionIdentifiers.blueprintName, + executionServiceInput.actionIdentifiers.blueprintVersion, + executionServiceInput.payload.toString(), + DatabaseStoreAuditConstants.WORKFLOW_STATUS_INPROGRESS, controllerDate(), + controllerDate(), controllerDate(), + DatabaseStoreAuditConstants.WORKFLOW_STATUS_UPDATEDBY, + executionServiceInput.actionIdentifiers.mode, "" + ) + + return storedAuditStatus.id + } + + /** + * store the blueprint workflow output to database + * @param auditStoreId + * @param correlationUUID + * @param executionServiceOutput {@link ExecutionServiceOutput} + * @throws {@link BluePrintException} + */ + override suspend fun storeExecutionOutput( + auditStoreId: Long, + correlationUUID: String, + executionServiceOutput: ExecutionServiceOutput + ) { + log.info( + "storeExecutionOutput called to store the Workflow action " + + "output details correlationUUID $correlationUUID " + + "auditStoreId $auditStoreId" + ) + try { + var storedAuditStatus: BlueprintWorkflowAuditStatus + + storedAuditStatus = + blueprintAuditStatusRepository.findById(auditStoreId) + if (storedAuditStatus == null) { + throw BluePrintException("Record not found exception") + } + storedAuditStatus.endDate = controllerDate() + storedAuditStatus.status = DatabaseStoreAuditConstants.WORKFLOW_STATUS_COMPLETED + storedAuditStatus.updatedDate = controllerDate() + ObjectMapper().writeValueAsString(executionServiceOutput.status) + storedAuditStatus.workflowResponseContent = ObjectMapper() + .writeValueAsString(executionServiceOutput) + + log.info( + "Update the Audit status record Id ${storedAuditStatus.id} " + + "bluePrintName ${storedAuditStatus.blueprintName}" + ) + blueprintAuditStatusRepository.saveAndFlush(storedAuditStatus) + } catch (ex: DataIntegrityViolationException) { + log.error( + "Error writing out BLUEPRINT_WORKFLOW_AUDIT_STATUS result: " + + "bpName:" + + " $auditStoreId" + + "correlationUUID $correlationUUID error: {}", + ex.message + ) + throw BluePrintException("Failed to store resource api result.", ex) + } + } + + /** + * retrive workflow records based on request ID + * @param requestId + * @return list of {@link BlueprintWorkflowAuditStatus} + */ + override suspend fun getWorkflowStatusByRequestId( + requestId: String + ): List<BlueprintWorkflowAuditStatus> { + log.info( + "getWorkflowStatusByRequestId called to retrieve all the records " + + "based on request Id" + ) + + var results: List<BlueprintWorkflowAuditStatus> = + blueprintAuditStatusRepository.findByRequestId(requestId) + log.info( + "getWorkflowStatusByRequestId results count " + + "${results.size}" + ) + return results + } + + /** + * Retrive workflow records based on request ID and sub request ID + * @param requestId + * @param subRequestId + * @return list of {@link BlueprintWorkflowAuditStatus} + */ + override suspend fun getWorkflowStatusByRequestIdAndSubRequestId( + requestId: String, + subRequestId: String + ): List<BlueprintWorkflowAuditStatus> { + log.info( + "getWorkflowStatusByRequestIdAndSubRequestId called to retrieve all the records " + + "based on request Id" + ) + + var results: List<BlueprintWorkflowAuditStatus> = + blueprintAuditStatusRepository.findByRequestIdAndSubRequestId(requestId, subRequestId) + log.info( + "getWorkflowStatusByRequestIdAndSubRequestId results count " + + "${results.size}" + ) + return results + } + + /** + * method to save input details to database + */ + suspend fun write( + id: Long, + originatorId: String, + requestId: String, + subRequestId: String, + workflowName: String, + blueprintName: String, + blueprintVersion: String, + workflowTaskContent: String, + status: String, + startDate: Date, + endDate: Date, + updatedDate: Date, + updatedBy: String, + requestMode: String, + workflowResponseContent: String + ): BlueprintWorkflowAuditStatus = + withContext(Dispatchers.IO) { + + val blueprintAuditStatusResult = BlueprintWorkflowAuditStatus() + + blueprintAuditStatusResult.originatorId = originatorId + blueprintAuditStatusResult.requestId = requestId + blueprintAuditStatusResult.subRequestId = subRequestId + blueprintAuditStatusResult.workflowName = workflowName + blueprintAuditStatusResult.blueprintName = blueprintName + blueprintAuditStatusResult.blueprintVersion = blueprintVersion + blueprintAuditStatusResult.workflowTaskContent = workflowTaskContent + blueprintAuditStatusResult.status = status + blueprintAuditStatusResult.startDate = startDate + blueprintAuditStatusResult.endDate = endDate + blueprintAuditStatusResult.updatedDate = updatedDate + blueprintAuditStatusResult.updatedBy = updatedBy + blueprintAuditStatusResult.requestMode = requestMode + blueprintAuditStatusResult.workflowResponseContent = + workflowResponseContent + + var storedAuditStatus: BlueprintWorkflowAuditStatus + try { + log.info( + "Writing out BLUEPRINT_AUDIT_STATUS result: bpName: " + + "$blueprintName bpVer $blueprintVersion " + + "id:$id" + + " (originatorId: $originatorId requestId: " + + "$requestId) subRequestId:$subRequestId" + ) + storedAuditStatus = blueprintAuditStatusRepository.saveAndFlush( + blueprintAuditStatusResult + ) + } catch (ex: DataIntegrityViolationException) { + log.error( + "Error writing out BLUEPRINT_AUDIT_STATUS result: bpName:" + + " $blueprintName bpVer $blueprintVersion " + + "id:$id" + + " (originatorId: $originatorId requestId:" + + " $requestId) subRequestId:$subRequestId error: {}", + ex.message + ) + throw BluePrintException( + "Failed to store resource api result.", + ex + ) + } + storedAuditStatus + } +} diff --git a/ms/blueprintsprocessor/functions/blueprint-audit-status/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/workflow/audit/NoStoreAuditService.kt b/ms/blueprintsprocessor/functions/blueprint-audit-status/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/workflow/audit/NoStoreAuditService.kt new file mode 100644 index 000000000..230e67852 --- /dev/null +++ b/ms/blueprintsprocessor/functions/blueprint-audit-status/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/workflow/audit/NoStoreAuditService.kt @@ -0,0 +1,118 @@ +/* + * Copyright © 2021 Aarna Networks, Inc. + * 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. + */ + +package org.onap.ccsdk.cds.blueprintsprocessor.functions.workflow.audit + +import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput +import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceOutput +import org.onap.ccsdk.cds.blueprintsprocessor.functions.workflow.audit.db.BlueprintAuditStatusRepository +import org.onap.ccsdk.cds.blueprintsprocessor.functions.workflow.audit.db.BlueprintWorkflowAuditStatus +import org.slf4j.LoggerFactory +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty +import org.springframework.stereotype.Service +import javax.annotation.PostConstruct + +/** + * Workflow request and response details are persisted to database + */ +@ConditionalOnProperty( + name = ["blueprintsprocessor.workflow.self-service-api.audit.storeEnable"], + havingValue = "false" +) +@Service +class NoStoreAuditService( + private val blueprintAuditStatusRepository: BlueprintAuditStatusRepository +) : StoreAuditService { + + private val log = + LoggerFactory.getLogger(NoStoreAuditService::class.toString()) + + @PostConstruct + fun init() { + log.info("Workflow Audit store is disabled") + } + /** + * store the blueprint workflow input details to database + * @param executionServiceInput {@link ExecutionServiceInput} + * @throws {@link BluePrintException} + */ + override suspend fun storeExecutionInput( + executionServiceInput: ExecutionServiceInput + ): Long { + log.info( + "storeExecutionInput called not to store the Workflow action " + + "input details " + ) + val resturnId: Long = -1 + return resturnId + } + + /** + * store the blueprint workflow output to database + * @param auditStoreId + * @param correlationUUID + * @param executionServiceOutput {@link ExecutionServiceOutput} + * @throws {@link BluePrintException} + */ + override suspend fun storeExecutionOutput( + auditStoreId: Long, + correlationUUID: String, + executionServiceOutput: ExecutionServiceOutput + ) { + log.info( + "storeExecutionOutput called not to store the Workflow action " + + "output details correlationUUID $correlationUUID " + + "auditStoreId $auditStoreId" + ) + } + + /** + * retrive workflow records based on request ID + * @param requestId + * @return list of {@link BlueprintWorkflowAuditStatus} + */ + override suspend fun getWorkflowStatusByRequestId( + requestId: String + ): List<BlueprintWorkflowAuditStatus> { + log.info( + "getWorkflowStatusByRequestId placeholer , this doesn't return " + + "any records" + ) + + var results: List<BlueprintWorkflowAuditStatus> = ArrayList<BlueprintWorkflowAuditStatus>() + return results + } + + /** + * Retrive workflow records based on request ID and sub request ID + * @param requestId + * @param subRequestId + * @return list of {@link BlueprintWorkflowAuditStatus} + */ + override suspend fun getWorkflowStatusByRequestIdAndSubRequestId( + requestId: String, + subRequestId: String + ): List<BlueprintWorkflowAuditStatus> { + log.info( + "getWorkflowStatusByRequestIdAndSubRequestId placeholer , this doesn't return " + + "any records" + ) + + var results: List<BlueprintWorkflowAuditStatus> = ArrayList<BlueprintWorkflowAuditStatus>() + + return results + } +} diff --git a/ms/blueprintsprocessor/functions/blueprint-audit-status/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/workflow/audit/StoreAuditService.kt b/ms/blueprintsprocessor/functions/blueprint-audit-status/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/workflow/audit/StoreAuditService.kt new file mode 100644 index 000000000..a2bfc1121 --- /dev/null +++ b/ms/blueprintsprocessor/functions/blueprint-audit-status/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/workflow/audit/StoreAuditService.kt @@ -0,0 +1,69 @@ +/* + * Copyright © 2021 Aarna Networks, Inc. + * 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. + */ + +package org.onap.ccsdk.cds.blueprintsprocessor.functions.workflow.audit + +import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput +import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceOutput +import org.onap.ccsdk.cds.blueprintsprocessor.functions.workflow.audit.db.BlueprintWorkflowAuditStatus + +/** + * Workflow request and response details are persisted to database + */ + +interface StoreAuditService { + + /** + * store the blueprint workflow input details to database + * @param executionServiceInput {@link ExecutionServiceInput} + * @throws {@link BluePrintException} + */ + suspend fun storeExecutionInput( + executionServiceInput: ExecutionServiceInput + ): Long + + /** + * store the blueprint workflow output to database + * @param auditStoreId + * @param correlationUUID + * @param executionServiceOutput {@link ExecutionServiceOutput} + */ + suspend fun storeExecutionOutput( + auditStoreId: Long, + correlationUUID: String, + executionServiceOutput: ExecutionServiceOutput + ) + + /** + * retrive workflow records based on request ID + * @param requestId + * @return list of {@link BlueprintWorkflowAuditStatus} + */ + suspend fun getWorkflowStatusByRequestId( + requestId: String + ): List<BlueprintWorkflowAuditStatus> + + /** + * Retrive workflow records based on request ID and sub request ID + * @param requestId + * @param subRequestId + * @return list of {@link BlueprintWorkflowAuditStatus} + */ + suspend fun getWorkflowStatusByRequestIdAndSubRequestId( + requestId: String, + subRequestId: String + ): List<BlueprintWorkflowAuditStatus> +} diff --git a/ms/blueprintsprocessor/functions/blueprint-audit-status/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/workflow/audit/db/BlueprintAuditStatusRepository.kt b/ms/blueprintsprocessor/functions/blueprint-audit-status/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/workflow/audit/db/BlueprintAuditStatusRepository.kt new file mode 100644 index 000000000..8e7304654 --- /dev/null +++ b/ms/blueprintsprocessor/functions/blueprint-audit-status/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/workflow/audit/db/BlueprintAuditStatusRepository.kt @@ -0,0 +1,107 @@ +/* + * Copyright © 2021 Aarna Networks, Inc. + * 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. + */ + +package org.onap.ccsdk.cds.blueprintsprocessor.functions.workflow.audit.db + +import org.springframework.data.jpa.repository.JpaRepository +import org.springframework.stereotype.Repository +import javax.transaction.Transactional + +/** + * JPA repository managing {@link BlueprintWorkflowAuditStatus} table. + */ +@Repository +interface BlueprintAuditStatusRepository : + JpaRepository<BlueprintWorkflowAuditStatus, String> { + + /** + * retireve records based on primary key ID. + * @param id + * @return {@link BlueprintWorkflowAuditStatus} + */ + fun findById(id: Long): BlueprintWorkflowAuditStatus + + /** + * retrieve records based on request ID + * @param requestId + * @return list {@link BlueprintWorkflowAuditStatus} + */ + fun findByRequestId( + requestId: String + ): List<BlueprintWorkflowAuditStatus> + + /** + * retrieve records based on request ID and subrequest ID + * @param requestId + * @param subRequestId + * @return list {@link BlueprintWorkflowAuditStatus} + */ + fun findByRequestIdAndSubRequestId( + requestId: String, + subRequestId: String + ): List<BlueprintWorkflowAuditStatus> + + /** + * retrieve records based on request id, blueprint name , blueprint version + * @param requestId + * @param blueprintName + * @param blueprintVersion + * @return {@link BlueprintWorkflowAuditStatus} + */ + fun findByRequestIdAndBlueprintNameAndBlueprintVersion( + requestId: String, + blueprintName: String?, + blueprintVersion: String? + ): BlueprintWorkflowAuditStatus + + /** + * retrieve records based on request id, blueprint name , blueprint version + * @return {@link BlueprintWorkflowAuditStatus} + */ + fun findByOriginatorIdAndRequestIdAndSubRequestIdAndWorkflowNameAndBlueprintNameAndBlueprintVersion( + originatorId: String, + requestId: String?, + subRequestId: String?, + workflowName: String, + blueprintName: String?, + blueprintVersion: String? + ): BlueprintWorkflowAuditStatus + + /** + * retrieve records based on request id, subrequest, originator, workflow, + * blueprint version, blueprint Name + * @return {@link BlueprintWorkflowAuditStatus} + */ + fun findByIdAndOriginatorIdAndRequestIdAndSubRequestIdAndWorkflowNameAndBlueprintNameAndBlueprintVersion( + id: Long, + originatorId: String, + requestId: String?, + subRequestId: String?, + workflowName: String, + blueprintName: String?, + blueprintVersion: String? + ): BlueprintWorkflowAuditStatus + + @Transactional + fun deleteByIdAndBlueprintNameAndBlueprintVersionAndOriginatorIdAndRequestIdAndSubRequestId( + id: Long, + blueprintName: String?, + blueprintVersion: String?, + originatorId: String, + requestId: String?, + subRequestId: String? + ) +} diff --git a/ms/blueprintsprocessor/functions/blueprint-audit-status/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/workflow/audit/db/BlueprintWorkflowAuditStatus.kt b/ms/blueprintsprocessor/functions/blueprint-audit-status/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/workflow/audit/db/BlueprintWorkflowAuditStatus.kt new file mode 100644 index 000000000..d9f0269f1 --- /dev/null +++ b/ms/blueprintsprocessor/functions/blueprint-audit-status/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/workflow/audit/db/BlueprintWorkflowAuditStatus.kt @@ -0,0 +1,136 @@ +/* + * Copyright © 2021 Aarna Networks, Inc. + * 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. + */ + +package org.onap.ccsdk.cds.blueprintsprocessor.functions.workflow.audit.db + +import com.fasterxml.jackson.annotation.JsonFormat +import io.swagger.annotations.ApiModelProperty +import org.hibernate.annotations.Proxy +import org.springframework.data.annotation.LastModifiedDate +import java.io.Serializable +import java.util.Date +import javax.persistence.Column +import javax.persistence.Entity +import javax.persistence.GenerationType +import javax.persistence.GeneratedValue +import javax.persistence.Id +import javax.persistence.Lob +import javax.persistence.Table +import javax.persistence.Temporal +import javax.persistence.TemporalType + +/** + * BlueprintWorkflowAuditStatus Model. + * Records stored and retrieved in table BLUEPRINT_WORKFLOW_AUDIT_STATUS is + * done through this entity. + */ +@Entity +@Table(name = "BLUEPRINT_WORKFLOW_AUDIT_STATUS") +@Proxy(lazy = false) +class BlueprintWorkflowAuditStatus : Serializable { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "workflow_audit_id") + var id: Long = 0 + + @get:ApiModelProperty(value = "Workflow payload.", required = true) + @Lob + @Column(name = "workflow_task_content", nullable = false) + @ApiModelProperty(required = true) + lateinit var workflowTaskContent: String + + @get:ApiModelProperty(value = "request originator Id", required = true) + @Column(name = "originator_Id", nullable = false) + @ApiModelProperty(required = true) + lateinit var originatorId: String + + @get:ApiModelProperty(value = "request Id", required = true) + @Column(name = "request_Id", nullable = false) + @ApiModelProperty(required = true) + lateinit var requestId: String + + @get:ApiModelProperty(value = "sub request Id", required = true) + @Column(name = "subRequest_Id", nullable = false) + @ApiModelProperty(required = true) + lateinit var subRequestId: String + + @get:ApiModelProperty(value = "workflow name", required = true) + @Column(name = "workflow_name", nullable = false) + @ApiModelProperty(required = true) + lateinit var workflowName: String + + @get:ApiModelProperty(value = "status", required = true) + @Column(name = "status", nullable = true) + @ApiModelProperty(required = true) + lateinit var status: String + + @get:ApiModelProperty( + value = "start time when request process started", required = true + ) + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") + @LastModifiedDate + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "start_time") + var startDate: Date = Date() + + @get:ApiModelProperty( + value = "end time when request process completed", required = true + ) + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") + @LastModifiedDate + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "end_time") + var endDate: Date = Date() + + @get:ApiModelProperty(value = "current date time", required = true) + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") + @LastModifiedDate + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "updated_date") + var updatedDate: Date = Date() + + @get:ApiModelProperty(value = "updated by", required = true) + @Column(name = "updated_by", nullable = true) + @ApiModelProperty(required = true) + lateinit var updatedBy: String + + @get:ApiModelProperty(value = "blueprint version", required = true) + @Column(name = "blueprint_version", nullable = false) + @ApiModelProperty(required = true) + lateinit var blueprintVersion: String + + @get:ApiModelProperty(value = "blueprint name", required = true) + @Column(name = "blueprint_name", nullable = false) + @ApiModelProperty(required = true) + lateinit var blueprintName: String + + @get:ApiModelProperty(value = "request mode", required = true) + @Column(name = "request_mode", nullable = true) + @ApiModelProperty(required = true) + lateinit var requestMode: String + + @get:ApiModelProperty(value = "workflow response content", required = false) + @Lob + @Column(name = "workflow_response_content", nullable = true) + @ApiModelProperty(required = false) + lateinit var workflowResponseContent: String + + @get:ApiModelProperty(value = "bluprint model uuid", required = true) + @Column(name = "blueprint_uuid", nullable = true) + @ApiModelProperty(required = false) + var blueprintUuid: String = "" +} |