6e277e5c8dc23e8f4251f86e36ed010141930851
[ccsdk/cds.git] / ms / blueprintsprocessor / modules / inbounds / designer-api / src / main / kotlin / org / onap / ccsdk / cds / blueprintsprocessor / designer / api / domain / ModelType.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.designer.api.domain
18
19 import com.fasterxml.jackson.annotation.JsonFormat
20 import com.fasterxml.jackson.databind.JsonNode
21 import io.swagger.annotations.ApiModelProperty
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 ModelType Entity
38  *
39  * @author Brinda Santh
40  * @version 1.0
41  */
42 @EntityListeners(AuditingEntityListener::class)
43 @Entity
44 @Table(name = "MODEL_TYPE")
45 class ModelType : Serializable {
46
47     @Id
48     @Column(name = "model_name", nullable = false)
49     @ApiModelProperty(required = true)
50     lateinit var modelName: String
51
52     @Column(name = "derived_from", nullable = false)
53     @ApiModelProperty(required = true)
54     lateinit var derivedFrom: String
55
56     @Column(name = "definition_type", nullable = false)
57     @ApiModelProperty(required = true)
58     lateinit var definitionType: String
59
60     @Lob
61     @Convert(converter = JpaJsonNodeConverter::class)
62     @Column(name = "definition", nullable = false)
63     @ApiModelProperty(required = true)
64     lateinit var definition: JsonNode
65
66     @Lob
67     @Column(name = "description", nullable = false)
68     @ApiModelProperty(required = true)
69     lateinit var description: String
70
71     @Column(name = "version", nullable = false)
72     @ApiModelProperty(required = true)
73     lateinit var version: String
74
75     @Lob
76     @Column(name = "tags", nullable = false)
77     @ApiModelProperty(required = true)
78     lateinit var tags: String
79
80     @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
81     @LastModifiedDate
82     @Temporal(TemporalType.TIMESTAMP)
83     @Column(name = "creation_date")
84     var creationDate: Date? = null
85
86     @Column(name = "updated_by", nullable = false)
87     @ApiModelProperty(required = true)
88     lateinit var updatedBy: String
89
90     override fun toString(): String {
91         return "[" + "modelName = " + modelName +
92                 ", derivedFrom = " + derivedFrom +
93                 ", definitionType = " + definitionType +
94                 ", description = " + description +
95                 ", creationDate = " + creationDate +
96                 ", version = " + version +
97                 ", updatedBy = " + updatedBy +
98                 ", tags = " + tags +
99                 "]"
100     }
101
102     companion object {
103         private const val serialVersionUID = 1L
104     }
105 }