Fix groupId for error-catalog
[ccsdk/cds.git] / ms / error-catalog / services / src / main / kotlin / org / onap / ccsdk / cds / error / catalog / services / domain / Domain.kt
1 /*
2  *  Copyright © 2020 IBM, 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.error.catalog.services.domain
18
19 import java.io.Serializable
20 import javax.persistence.CascadeType
21 import javax.persistence.Column
22 import javax.persistence.Entity
23 import javax.persistence.FetchType
24 import javax.persistence.Id
25 import javax.persistence.Lob
26 import javax.persistence.ManyToMany
27 import javax.persistence.Table
28 import javax.persistence.UniqueConstraint
29 import java.util.UUID
30 import javax.persistence.JoinTable
31 import javax.persistence.JoinColumn
32
33 /**
34  *  Provide ErrorCode Entity
35  *
36  * @author Steve Siani
37  * @version 1.0
38  */
39
40 @Entity
41 @Table(name = "ERROR_DOMAINS", uniqueConstraints = [UniqueConstraint(columnNames = ["name", "application_id"])])
42 class Domain : Serializable {
43     @Id
44     var id: String = UUID.randomUUID().toString()
45
46     @Column(name = "name")
47     lateinit var name: String
48
49     @Column(name = "application_id")
50     lateinit var applicationId: String
51
52     @Lob
53     @Column(name = "description")
54     var description: String = ""
55
56     @ManyToMany(fetch = FetchType.EAGER, cascade = [CascadeType.ALL])
57     @JoinTable(
58         name = "ERROR_DOMAINS_ERROR_MESSAGES",
59         joinColumns = [JoinColumn(name = "domain_id", referencedColumnName = "id")],
60         inverseJoinColumns = [JoinColumn(name = "message_id", referencedColumnName = "id")]
61     )
62     @Column(name = "error_msg")
63     val errorMessages: MutableSet<ErrorMessageModel> = mutableSetOf()
64
65     constructor()
66
67     constructor(name: String, applicationId: String, description: String) {
68         this.name = name
69         this.description = description
70         this.applicationId = applicationId
71     }
72
73     companion object {
74         private const val serialVersionUID = 1L
75     }
76 }