-
Notifications
You must be signed in to change notification settings - Fork 188
/
RNode.java
93 lines (77 loc) · 3.08 KB
/
RNode.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
/*
* Copyright (c) 2010-2013 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
*/
package com.evolveum.midpoint.repo.sql.data.common;
import com.evolveum.midpoint.repo.sql.data.RepositoryContext;
import com.evolveum.midpoint.repo.sql.data.common.embedded.RPolyString;
import com.evolveum.midpoint.repo.sql.query.definition.JaxbName;
import com.evolveum.midpoint.repo.sql.query.definition.NeverNull;
import com.evolveum.midpoint.repo.sql.util.DtoTranslationException;
import com.evolveum.midpoint.repo.sql.util.IdGeneratorResult;
import com.evolveum.midpoint.repo.sql.util.MidPointJoinedPersister;
import com.evolveum.midpoint.xml.ns._public.common.common_3.NodeType;
import org.hibernate.annotations.ForeignKey;
import org.hibernate.annotations.Persister;
import javax.persistence.*;
/**
* @author lazyman
*/
@Entity
@ForeignKey(name = "fk_node")
@Table(uniqueConstraints = @UniqueConstraint(name = "uc_node_name", columnNames = {"name_norm"}),
indexes = {
@Index(name = "iNodeNameOrig", columnList = "name_orig"),
}
)
@Persister(impl = MidPointJoinedPersister.class)
public class RNode extends RObject {
private RPolyString nameCopy;
private String nodeIdentifier;
public String getNodeIdentifier() {
return nodeIdentifier;
}
@JaxbName(localPart = "name")
@AttributeOverrides({
@AttributeOverride(name = "orig", column = @Column(name = "name_orig")),
@AttributeOverride(name = "norm", column = @Column(name = "name_norm"))
})
@Embedded
@NeverNull
public RPolyString getNameCopy() {
return nameCopy;
}
public void setNameCopy(RPolyString nameCopy) {
this.nameCopy = nameCopy;
}
public void setNodeIdentifier(String nodeIdentifier) {
this.nodeIdentifier = nodeIdentifier;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (!super.equals(o)) return false;
RNode rNode = (RNode) o;
if (nameCopy != null ? !nameCopy.equals(rNode.nameCopy) : rNode.nameCopy != null) return false;
if (nodeIdentifier != null ? !nodeIdentifier.equals(rNode.nodeIdentifier) : rNode.nodeIdentifier != null)
return false;
return true;
}
@Override
public int hashCode() {
int result = super.hashCode();
result = 31 * result + (nameCopy != null ? nameCopy.hashCode() : 0);
result = 31 * result + (nodeIdentifier != null ? nodeIdentifier.hashCode() : 0);
return result;
}
// dynamically called
public static void copyFromJAXB(NodeType jaxb, RNode repo, RepositoryContext repositoryContext,
IdGeneratorResult generatorResult) throws DtoTranslationException {
copyObjectInformationFromJAXB(jaxb, repo, repositoryContext, generatorResult);
repo.setNameCopy(RPolyString.copyFromJAXB(jaxb.getName()));
repo.setNodeIdentifier(jaxb.getNodeIdentifier());
}
}