e0d26a7ae11893c8f118c7f463c4d8edb02860ec
[ccsdk/cds.git] / ms / blueprintsprocessor / modules / commons / db-lib / src / main / kotlin / org / onap / ccsdk / cds / blueprintsprocessor / db / primary / domain / BlueprintModelContent.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.springframework.data.annotation.LastModifiedDate
22 import org.springframework.data.jpa.domain.support.AuditingEntityListener
23 import java.io.Serializable
24 import java.util.*
25 import javax.persistence.*
26
27 /**
28  * Provide Blueprint Model Content Entity
29  *
30  * @author Brinda Santh
31  * @version 1.0
32  */
33 @EntityListeners(AuditingEntityListener::class)
34 @Entity
35 @Table(name = "CONFIG_MODEL_CONTENT")
36 class BlueprintModelContent : Serializable {
37
38     @Id
39     @Column(name = "config_model_content_id")
40     var id: String? = null
41
42     @Column(name = "name", nullable = false)
43     @ApiModelProperty(required = true)
44     lateinit var name: String
45
46     @Column(name = "content_type", nullable = false)
47     @ApiModelProperty(required = true)
48     lateinit var contentType: String
49
50     @OneToOne
51     @JoinColumn(name = "config_model_id")
52     var blueprintModel: BlueprintModel? = null
53
54     @Lob
55     @Column(name = "description")
56     var description: String? = null
57
58     @Lob
59     @Column(name = "content", nullable = false)
60     @ApiModelProperty(required = true)
61     lateinit var content: ByteArray
62
63     @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
64     @LastModifiedDate
65     @Temporal(TemporalType.TIMESTAMP)
66     @Column(name = "updated_date")
67     var creationDate = Date()
68
69     override fun toString(): String {
70         return "[" + "id = " + id +
71                 ", name = " + name +
72                 ", contentType = " + contentType +
73                 "]"
74     }
75
76     override fun equals(o: Any?): Boolean {
77
78         if (o === this) {
79             return true
80         }
81         if (o !is BlueprintModelContent) {
82             return false
83         }
84         val blueprintModelContent = o as BlueprintModelContent?
85         return (id == blueprintModelContent!!.id && name == blueprintModelContent.name
86                 && contentType == blueprintModelContent.contentType)
87     }
88
89     override fun hashCode(): Int {
90         return Objects.hash(id, name, contentType)
91     }
92
93     companion object {
94
95         private const val serialVersionUID = 1L
96     }
97
98 }