36a5470320e4842a254b85f49c2bcdf8379e8fd4
[ccsdk/cds.git] /
1 /*
2  * Copyright © 2019 Bell Canada
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package org.onap.ccsdk.cds.blueprintsprocessor.functions.config.snapshots.db
18
19 import com.fasterxml.jackson.annotation.JsonFormat
20 import io.swagger.annotations.ApiModelProperty
21 import org.hibernate.annotations.Proxy
22 import org.springframework.data.annotation.LastModifiedDate
23 import org.springframework.data.jpa.domain.support.AuditingEntityListener
24 import java.io.Serializable
25 import java.util.*
26 import javax.persistence.Column
27 import javax.persistence.Entity
28 import javax.persistence.EntityListeners
29 import javax.persistence.Id
30 import javax.persistence.Lob
31 import javax.persistence.Table
32 import javax.persistence.Temporal
33 import javax.persistence.TemporalType
34
35 /**
36  * ResourceConfigSnapshot model
37  * Stores RUNNING or CANDIDATE resource configuration snapshots, captured during the execution
38  * of blueprints.  A resource is identified by an identifier and a type.
39  *
40  * @author Serge Simard
41  * @version 1.0
42  */
43 @EntityListeners(AuditingEntityListener::class)
44 @Entity
45 @Table(name = "RESOURCE_CONFIG_SNAPSHOT")
46 @Proxy(lazy = false)
47 class ResourceConfigSnapshot : Serializable {
48
49     @get:ApiModelProperty(value = "Resource type.", required = true, example = "ServiceInstance, VfModule, VNF, PNF")
50     @Column(name = "resource_type", nullable = false)
51     var resourceType: String? = null
52
53     @get:ApiModelProperty(value = "ID associated with the resource type in the inventory system.", required = true)
54     @Column(name = "resource_id", nullable = false)
55     var resourceId: String? = null
56
57     @get:ApiModelProperty(value = "Status of the snapshot, either running or candidate.", required = true)
58     @Column(name = "status", nullable = false)
59     var status: Status? = null
60
61     @get:ApiModelProperty(value = "Snapshot of the resource as retrieved from resource.", required = true)
62     @Lob
63     @Column(name = "config_snapshot", nullable = false)
64     var config_snapshot: String? = null
65
66     @Id
67     @Column(name = "resource_config_snapshot_id")
68     var id: String? = null
69
70     @get:ApiModelProperty(value = "Creation date of the snapshot.", required = true)
71     @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
72     @LastModifiedDate
73     @Temporal(TemporalType.TIMESTAMP)
74     @Column(name = "creation_date")
75     var createdDate = Date()
76
77     companion object {
78         private const val serialVersionUID = 1L
79     }
80
81     enum class Status(val state: String) {
82         RUNNING("RUNNING"),
83         CANDIDATE("CANDIDATE")
84     }
85 }