5dac6b5e594a8b556147bf67129563836073df86
[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.ApiModel
21 import io.swagger.annotations.ApiModelProperty
22 import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceDefinition
23 import org.springframework.data.annotation.LastModifiedDate
24 import org.springframework.data.jpa.domain.support.AuditingEntityListener
25 import java.io.Serializable
26 import java.util.Date
27 import javax.persistence.Column
28 import javax.persistence.Convert
29 import javax.persistence.Entity
30 import javax.persistence.EntityListeners
31 import javax.persistence.Id
32 import javax.persistence.Lob
33 import javax.persistence.Table
34 import javax.persistence.Temporal
35 import javax.persistence.TemporalType
36
37 /**
38  * Provide ResourceDictionary Entity
39  *
40  * @author Brinda Santh
41  * @version 1.0
42  */
43 @EntityListeners(AuditingEntityListener::class)
44 @ApiModel
45 @Entity
46 @Table(name = "RESOURCE_DICTIONARY")
47 class ResourceDictionary : Serializable {
48
49     @Id
50     @Column(name = "name", nullable = false)
51     @ApiModelProperty(value = "Name", required = true, example = "\"sample-db-source\"")
52     lateinit var name: String
53
54     @Column(name = "data_type", nullable = false)
55     @ApiModelProperty(value = "Data type", required = true, example = "\"string\"")
56     lateinit var dataType: String
57
58     @Column(name = "entry_schema")
59     @ApiModelProperty(value = "Entry schema", required = true, example = "\"dt-license-key\"")
60     var entrySchema: String? = null
61
62     @Column(name = "resource_dictionary_group")
63     @ApiModelProperty(value = "Resource dictionary group", required = true, example = "\"default\"")
64     var resourceDictionaryGroup: String? = null
65
66     @Lob
67     @Convert(converter = JpaResourceDefinitionConverter::class)
68     @Column(name = "definition", nullable = false)
69     @ApiModelProperty(value = "Definition", required = true)
70     lateinit var definition: ResourceDefinition
71
72     @Lob
73     @Column(name = "description", nullable = false)
74     @ApiModelProperty(value = "Description", required = true, example = "\"demo_artifacts_version\"")
75     lateinit var description: String
76
77     @Lob
78     @Column(name = "tags", nullable = false)
79     @ApiModelProperty(value = "Tags", required = true, example = "\"hostname\"")
80     lateinit var tags: String
81
82     @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
83     @LastModifiedDate
84     @Temporal(TemporalType.TIMESTAMP)
85     @Column(name = "creation_date")
86     var creationDate: Date? = null
87
88     @Column(name = "updated_by", nullable = false)
89     @ApiModelProperty(value = "Updated by", required = true, example = "\"username\"")
90     lateinit var updatedBy: String
91
92     override fun toString(): String {
93         return "[" + ", name = " + name +
94             ", dataType = " + dataType +
95             ", entrySchema = " + entrySchema +
96             ", resourceDictionaryGroup = " + resourceDictionaryGroup +
97             ", definition =" + definition +
98             ", description = " + description +
99             ", updatedBy = " + updatedBy +
100             ", tags = " + tags +
101             ", creationDate = " + creationDate +
102             "]"
103     }
104
105     companion object {
106
107         private const val serialVersionUID = 1L
108     }
109 }