a964e0416c3bc0d8b9c655ea5edfb3bbf8d5ea35
[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 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.*
26 import javax.persistence.*
27
28 /**
29  * Provide ModelType Entity
30  *
31  * @author Brinda Santh
32  * @version 1.0
33  */
34 @EntityListeners(AuditingEntityListener::class)
35 @Entity
36 @Table(name = "MODEL_TYPE")
37 class ModelType : Serializable {
38
39     @Id
40     @Column(name = "model_name", nullable = false)
41     @ApiModelProperty(required = true)
42     lateinit var modelName: String
43
44     @Column(name = "derived_from", nullable = false)
45     @ApiModelProperty(required = true)
46     lateinit var derivedFrom: String
47
48     @Column(name = "definition_type", nullable = false)
49     @ApiModelProperty(required = true)
50     lateinit var definitionType: String
51
52     @Lob
53     @Convert(converter = JpaJsonNodeConverter::class)
54     @Column(name = "definition", nullable = false)
55     @ApiModelProperty(required = true)
56     lateinit var definition: JsonNode
57
58     @Lob
59     @Column(name = "description", nullable = false)
60     @ApiModelProperty(required = true)
61     lateinit var description: String
62
63     @Column(name = "version", nullable = false)
64     @ApiModelProperty(required = true)
65     lateinit var version: String
66
67     @Lob
68     @Column(name = "tags", nullable = false)
69     @ApiModelProperty(required = true)
70     lateinit var tags: String
71
72     @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
73     @LastModifiedDate
74     @Temporal(TemporalType.TIMESTAMP)
75     @Column(name = "creation_date")
76     var creationDate: Date? = null
77
78     @Column(name = "updated_by", nullable = false)
79     @ApiModelProperty(required = true)
80     lateinit var updatedBy: String
81
82     override fun toString(): String {
83         return "[" + "modelName = " + modelName +
84                 ", derivedFrom = " + derivedFrom +
85                 ", definitionType = " + definitionType +
86                 ", description = " + description +
87                 ", creationDate = " + creationDate +
88                 ", version = " + version +
89                 ", updatedBy = " + updatedBy +
90                 ", tags = " + tags +
91                 "]"
92     }
93
94     companion object {
95         private const val serialVersionUID = 1L
96     }
97 }