6a7a2cd17d46724f6835eb18c64c2052d1b6e346
[ccsdk/cds.git] /
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.functions.resource.resolution.db
18
19 import com.fasterxml.jackson.annotation.JsonFormat
20 import io.swagger.annotations.ApiModelProperty
21 import org.hibernate.annotations.Proxy
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.Entity
28 import javax.persistence.EntityListeners
29 import javax.persistence.Id
30 import javax.persistence.Index
31 import javax.persistence.Lob
32 import javax.persistence.Table
33 import javax.persistence.Temporal
34 import javax.persistence.TemporalType
35
36 @EntityListeners(AuditingEntityListener::class)
37 @Entity
38 @Table(
39     name = "TEMPLATE_RESOLUTION",
40     indexes = [
41         Index(name = "idx_tr_bpnameversion", columnList = "blueprint_name, blueprint_version"),
42         Index(name = "idx_tr_resource_idtype", columnList = "resource_id, resource_type"),
43         Index(name = "idx_tr_artifact_name", columnList = "artifact_name"),
44         Index(name = "idx_tr_resolution_key", columnList = "resolution_key")
45     ]
46 )
47 @Proxy(lazy = false)
48 class TemplateResolution : Serializable {
49
50     @get:ApiModelProperty(value = "Name of the CBA.", required = true)
51     @Column(name = "blueprint_name", nullable = false)
52     var blueprintName: String? = null
53
54     @get:ApiModelProperty(value = "Version of the CBA.", required = true)
55     @Column(name = "blueprint_version", nullable = false)
56     var blueprintVersion: String? = null
57
58     @get:ApiModelProperty(value = "Artifact name for which to retrieve a resolved resource.", required = true)
59     @Column(name = "artifact_name", nullable = false)
60     var artifactName: String? = null
61
62     @get:ApiModelProperty(value = "Rendered template.", required = true)
63     @Lob
64     @Column(name = "result", nullable = false)
65     var result: String? = null
66
67     @get:ApiModelProperty(
68         value = "Resolution Key uniquely identifying the resolution of a given artifact within a CBA.",
69         required = true
70     )
71     @Column(name = "resolution_key", nullable = false)
72     var resolutionKey: String? = null
73
74     @get:ApiModelProperty(value = "Resolution type.", required = true, example = "\"ServiceInstance\"")
75     @Column(name = "resource_type", nullable = false)
76     var resourceType: String? = null
77
78     @get:ApiModelProperty(value = "ID associated with the resolution type in the inventory system.", required = true)
79     @Column(name = "resource_id", nullable = false)
80     var resourceId: String? = null
81
82     @get:ApiModelProperty(
83         value = "If resolution occurred multiple time, this field provides the index.",
84         required = true
85     )
86     @Column(name = "occurrence", nullable = false)
87     var occurrence: Int = 1
88
89     @Id
90     @Column(name = "template_resolution_id")
91     var id: String? = null
92
93     @get:ApiModelProperty(value = "Creation date of the resolution.", required = true)
94     @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
95     @LastModifiedDate
96     @Temporal(TemporalType.TIMESTAMP)
97     @Column(name = "creation_date")
98     var createdDate = Date()
99
100     companion object {
101
102         private const val serialVersionUID = 1L
103     }
104 }