Formatting Code base with ktlint
[ccsdk/cds.git] / ms / blueprintsprocessor / modules / commons / db-lib / src / main / kotlin / org / onap / ccsdk / cds / blueprintsprocessor / db / primary / domain / BlueprintModel.kt
1 /*
2  *  Copyright © 2019 IBM.
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.db.primary.domain
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.Date
26 import javax.persistence.CascadeType
27 import javax.persistence.Column
28 import javax.persistence.Entity
29 import javax.persistence.EntityListeners
30 import javax.persistence.FetchType
31 import javax.persistence.Id
32 import javax.persistence.Lob
33 import javax.persistence.OneToOne
34 import javax.persistence.Table
35 import javax.persistence.Temporal
36 import javax.persistence.TemporalType
37 import javax.persistence.UniqueConstraint
38
39 /**
40  *  Provide BlueprintModel Entity
41  *
42  * @author Brinda Santh
43  * @version 1.0
44  */
45
46 @EntityListeners(AuditingEntityListener::class)
47 @Entity
48 @Table(name = "BLUEPRINT_MODEL", uniqueConstraints = [UniqueConstraint(columnNames = ["artifact_name", "artifact_version"])])
49 @Proxy(lazy = false)
50 class BlueprintModel : Serializable {
51
52     @Id
53     @Column(name = "blueprint_model_id")
54     var id: String? = null
55
56     @Column(name = "service_uuid")
57     var serviceUUID: String? = null
58
59     @Column(name = "distribution_id")
60     var distributionId: String? = null
61
62     @Column(name = "service_name")
63     var serviceName: String? = null
64
65     @Column(name = "service_description")
66     var serviceDescription: String? = null
67
68     @Column(name = "resource_uuid")
69     var resourceUUID: String? = null
70
71     @Column(name = "resource_instance_name")
72     var resourceInstanceName: String? = null
73
74     @Column(name = "resource_name")
75     var resourceName: String? = null
76
77     @Column(name = "resource_version")
78     var resourceVersion: String? = null
79
80     @Column(name = "resource_type")
81     var resourceType: String? = null
82
83     @Column(name = "artifact_uuid")
84     var artifactUUId: String? = null
85
86     @Column(name = "artifact_type")
87     var artifactType: String? = null
88
89     @Column(name = "artifact_version", nullable = false)
90     @ApiModelProperty(required = true)
91     lateinit var artifactVersion: String
92
93     @Lob
94     @Column(name = "artifact_description")
95     var artifactDescription: String? = null
96
97     @Column(name = "internal_version")
98     var internalVersion: Int? = null
99
100     @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
101     @LastModifiedDate
102     @Temporal(TemporalType.TIMESTAMP)
103     @Column(name = "creation_date")
104     var createdDate = Date()
105
106     @Column(name = "artifact_name", nullable = false)
107     @ApiModelProperty(required = true)
108     lateinit var artifactName: String
109
110     @Column(name = "published", nullable = false)
111     @ApiModelProperty(required = true)
112     lateinit var published: String
113
114     @Column(name = "updated_by", nullable = false)
115     @ApiModelProperty(required = true)
116     lateinit var updatedBy: String
117
118     @Lob
119     @Column(name = "tags", nullable = false)
120     @ApiModelProperty(required = true)
121     lateinit var tags: String
122
123     @OneToOne(mappedBy = "blueprintModel", fetch = FetchType.EAGER, orphanRemoval = true, cascade = [CascadeType.ALL])
124     var blueprintModelContent: BlueprintModelContent? = null
125
126     companion object {
127         private const val serialVersionUID = 1L
128     }
129 }