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