-
Notifications
You must be signed in to change notification settings - Fork 188
/
RAExtLong.java
184 lines (151 loc) · 5.13 KB
/
RAExtLong.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
/*
* Copyright (c) 2010-2013 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.evolveum.midpoint.repo.sql.data.common.any;
import com.evolveum.midpoint.repo.sql.data.common.id.RAExtLongId;
import com.evolveum.midpoint.repo.sql.data.common.type.RAssignmentExtensionType;
import com.evolveum.midpoint.repo.sql.util.RUtil;
import org.hibernate.annotations.ForeignKey;
import org.hibernate.annotations.Index;
import javax.persistence.*;
/**
* @author lazyman
*/
@Entity
@IdClass(RAExtLongId.class)
@Table(name = "m_assignment_ext_long")
@org.hibernate.annotations.Table(appliesTo = "m_assignment_ext_long",
indexes = {@Index(name = "iAExtensionLong", columnNames = {"extensionType", "longValue", "eName", "eType"})})
public class RAExtLong implements RAExtValue {
//owner entity
private RAssignmentExtension anyContainer;
private String ownerOid;
private Short ownerId;
private RAssignmentExtensionType extensionType;
private boolean dynamic;
private String name;
private String type;
private RValueType valueType;
private Long value;
public RAExtLong() {
}
public RAExtLong(Long value) {
this.value = value;
}
@ForeignKey(name = "fk_assignment_ext_long")
@MapsId("owner")
@ManyToOne(fetch = FetchType.LAZY)
@PrimaryKeyJoinColumns({
@PrimaryKeyJoinColumn(name = "anyContainer_owner_owner_oid", referencedColumnName = "ownerOid"),
@PrimaryKeyJoinColumn(name = "anyContainer_owner_id", referencedColumnName = "owner_type")
})
public RAssignmentExtension getAnyContainer() {
return anyContainer;
}
@Id
@Column(name = "anyContainer_owner_owner_oid", length = RUtil.COLUMN_LENGTH_OID)
public String getOwnerOid() {
if (ownerOid == null && anyContainer != null) {
ownerOid = anyContainer.getOwnerOid();
}
return ownerOid;
}
@Id
@Column(name = "anyContainer_owner_id")
public Short getOwnerId() {
if (ownerId == null && anyContainer != null) {
ownerId = anyContainer.getOwnerId();
}
return ownerId;
}
@Id
@Enumerated(EnumType.ORDINAL)
public RAssignmentExtensionType getExtensionType() {
return extensionType;
}
@Id
@Column(name = "eName", length = RUtil.COLUMN_LENGTH_QNAME)
public String getName() {
return name;
}
@Id
@Column(name = "eType", length = RUtil.COLUMN_LENGTH_QNAME)
public String getType() {
return type;
}
@Enumerated(EnumType.ORDINAL)
public RValueType getValueType() {
return valueType;
}
/**
* @return true if this property has dynamic definition
*/
@Column(name = "dynamicDef")
public boolean isDynamic() {
return dynamic;
}
@Column(name = "longValue")
public Long getValue() {
return value;
}
public void setValue(Long value) {
this.value = value;
}
public void setValueType(RValueType valueType) {
this.valueType = valueType;
}
public void setName(String name) {
this.name = name;
}
public void setType(String type) {
this.type = type;
}
public void setDynamic(boolean dynamic) {
this.dynamic = dynamic;
}
public void setAnyContainer(RAssignmentExtension anyContainer) {
this.anyContainer = anyContainer;
}
public void setOwnerOid(String ownerOid) {
this.ownerOid = ownerOid;
}
public void setOwnerId(Short ownerId) {
this.ownerId = ownerId;
}
public void setExtensionType(RAssignmentExtensionType extensionType) {
this.extensionType = extensionType;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
RAExtLong that = (RAExtLong) o;
if (dynamic != that.dynamic) return false;
if (name != null ? !name.equals(that.name) : that.name != null) return false;
if (type != null ? !type.equals(that.type) : that.type != null) return false;
if (valueType != that.valueType) return false;
if (value != null ? !value.equals(that.value) : that.value != null) return false;
return true;
}
@Override
public int hashCode() {
int result = (dynamic ? 1 : 0);
result = 31 * result + (name != null ? name.hashCode() : 0);
result = 31 * result + (type != null ? type.hashCode() : 0);
result = 31 * result + (valueType != null ? valueType.hashCode() : 0);
result = 31 * result + (value != null ? value.hashCode() : 0);
return result;
}
}