2 * ============LICENSE_START==========================================
4 * ===================================================================
5 * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
6 * ===================================================================
7 * Modifications Copyright (c) 2019 Samsung
8 * ===================================================================
10 * Unless otherwise specified, all software contained herein is licensed
11 * under the Apache License, Version 2.0 (the "License");
12 * you may not use this software except in compliance with the License.
13 * You may obtain a copy of the License at
15 * http://www.apache.org/licenses/LICENSE-2.0
17 * Unless required by applicable law or agreed to in writing, software
18 * distributed under the License is distributed on an "AS IS" BASIS,
19 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 * See the License for the specific language governing permissions and
21 * limitations under the License.
23 * Unless otherwise specified, all documentation contained herein is licensed
24 * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
25 * you may not use this documentation except in compliance with the License.
26 * You may obtain a copy of the License at
28 * https://creativecommons.org/licenses/by/4.0/
30 * Unless required by applicable law or agreed to in writing, documentation
31 * distributed under the License is distributed on an "AS IS" BASIS,
32 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
33 * See the License for the specific language governing permissions and
34 * limitations under the License.
36 * ============LICENSE_END============================================
41 package org.onap.portal.domain.db;
43 import java.io.ByteArrayInputStream;
44 import java.io.ByteArrayOutputStream;
45 import java.io.ObjectInputStream;
46 import java.io.ObjectOutputStream;
47 import java.io.Serializable;
48 import java.time.LocalDateTime;
50 import javax.persistence.CascadeType;
51 import javax.persistence.Column;
52 import javax.persistence.Entity;
53 import javax.persistence.FetchType;
54 import javax.persistence.GeneratedValue;
55 import javax.persistence.GenerationType;
56 import javax.persistence.Id;
57 import javax.persistence.Index;
58 import javax.persistence.Inheritance;
59 import javax.persistence.InheritanceType;
60 import javax.persistence.JoinColumn;
61 import javax.persistence.ManyToOne;
62 import javax.persistence.OneToMany;
63 import javax.persistence.SequenceGenerator;
64 import javax.persistence.Table;
65 import javax.validation.constraints.Digits;
66 import lombok.AllArgsConstructor;
68 import lombok.NoArgsConstructor;
70 import org.onap.portal.domain.db.fn.FnUser;
71 import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
73 @Table(name = "domain")
79 @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
80 public class DomainVo implements Serializable, Cloneable, Comparable {
82 private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(DomainVo.class);
83 private static final long serialVersionUID = 1L;
86 @GeneratedValue(strategy = GenerationType.AUTO)
87 @Column(name = "id", length = 11, nullable = false, columnDefinition = "bigint AUTO_INCREMENT")
88 @Digits(integer = 11, fraction = 0)
90 private LocalDateTime created;
91 private LocalDateTime modified;
93 private Serializable auditUserId;
95 @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE)
96 @JoinColumn(name = "created_id", columnDefinition = "bigint")
97 private DomainVo createdId;
98 @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE)
99 @JoinColumn(name = "modified_id", columnDefinition = "bigint")
100 private DomainVo modifiedId;
103 targetEntity = DomainVo.class,
104 mappedBy = "createdId",
105 cascade = CascadeType.MERGE,
106 fetch = FetchType.LAZY
108 private Set<DomainVo> fnUsersCreatedId;
110 targetEntity = DomainVo.class,
111 mappedBy = "modifiedId",
112 cascade = CascadeType.MERGE,
113 fetch = FetchType.LAZY
115 private Set<DomainVo> fnUsersModifiedId;
117 public DomainVo(Long id) {
122 public int compareTo(Object obj) {
123 Long c1 = this.getId();
124 Long c2 = ((org.onap.portalsdk.core.domain.support.DomainVo) obj).getId();
125 return c1 != null && c2 != null ? c1.compareTo(c2) : 1;
128 public Object copy(boolean isIdNull) {
129 ByteArrayOutputStream baos = null;
130 ByteArrayInputStream bais = null;
131 ObjectOutputStream oos = null;
132 ObjectInputStream ois = null;
133 DomainVo newVo = null;
136 baos = new ByteArrayOutputStream();
137 oos = new ObjectOutputStream(baos);
138 oos.writeObject(this);
139 bais = new ByteArrayInputStream(baos.toByteArray());
140 ois = new ObjectInputStream(bais);
141 newVo = (DomainVo) ois.readObject();
145 } catch (Exception var8) {
146 logger.error("exception occured", var8);
152 public Object clone() throws CloneNotSupportedException {
153 return super.clone();
156 public boolean equals(Object other) {
159 } else if (other == null) {
161 } else if (!(other instanceof DomainVo)) {
164 DomainVo castOther = (DomainVo) other;
165 return this.getId().equals(castOther.getId())
166 && this.getCreated().equals(castOther.getCreated())
167 && this.getModified().equals(castOther.getModified());
171 public DomainVo(DomainVo domainVo) {
172 this.id = domainVo.id;
173 this.created = domainVo.created;
174 this.modified = domainVo.modified;
175 this.rowNum = domainVo.rowNum;
176 this.auditUserId = domainVo.auditUserId;