209e2bbe8191df3a43d01dd407958354d3dbbac4
[ccsdk/cds.git] /
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.designer.api.domain
18
19 import com.fasterxml.jackson.annotation.JsonFormat
20 import io.swagger.annotations.ApiModelProperty
21 import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceDefinition
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.Column
27 import javax.persistence.Convert
28 import javax.persistence.Entity
29 import javax.persistence.EntityListeners
30 import javax.persistence.Id
31 import javax.persistence.Lob
32 import javax.persistence.Table
33 import javax.persistence.Temporal
34 import javax.persistence.TemporalType
35
36 /**
37  * Provide ResourceDictionary Entity
38  *
39  * @author Brinda Santh
40  * @version 1.0
41  */
42 @EntityListeners(AuditingEntityListener::class)
43 @Entity
44 @Table(name = "RESOURCE_DICTIONARY")
45 class ResourceDictionary : Serializable {
46
47     @Id
48     @Column(name = "name", nullable = false)
49     @ApiModelProperty(required = true)
50     lateinit var name: String
51
52     @Column(name = "data_type", nullable = false)
53     @ApiModelProperty(required = true)
54     lateinit var dataType: String
55
56     @Column(name = "entry_schema")
57     var entrySchema: String? = null
58
59     @Lob
60     @Convert(converter = JpaResourceDefinitionConverter::class)
61     @Column(name = "definition", nullable = false)
62     @ApiModelProperty(required = true)
63     lateinit var definition: ResourceDefinition
64
65     @Lob
66     @Column(name = "description", nullable = false)
67     @ApiModelProperty(required = true)
68     lateinit var description: String
69
70     @Lob
71     @Column(name = "tags", nullable = false)
72     @ApiModelProperty(required = true)
73     lateinit var tags: String
74
75     @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
76     @LastModifiedDate
77     @Temporal(TemporalType.TIMESTAMP)
78     @Column(name = "creation_date")
79     var creationDate: Date? = null
80
81     @Column(name = "updated_by", nullable = false)
82     @ApiModelProperty(required = true)
83     lateinit var updatedBy: String
84
85     override fun toString(): String {
86         return "[" + ", name = " + name +
87                 ", dataType = " + dataType +
88                 ", entrySchema = " + entrySchema +
89                 ", definition =" + definition +
90                 ", description = " + description +
91                 ", updatedBy = " + updatedBy +
92                 ", tags = " + tags +
93                 ", creationDate = " + creationDate +
94                 "]"
95     }
96
97     companion object {
98         private const val serialVersionUID = 1L
99     }
100 }