-
Notifications
You must be signed in to change notification settings - Fork 188
/
ItemPathDto.java
97 lines (74 loc) · 2.18 KB
/
ItemPathDto.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
package com.evolveum.midpoint.gui.api.component.path;
import java.io.Serializable;
import javax.xml.namespace.QName;
import com.evolveum.midpoint.prism.ItemDefinition;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType;
import com.evolveum.prism.xml.ns._public.types_3.ItemPathType;
public class ItemPathDto implements Serializable{
private static final long serialVersionUID = 1L;
private QName objectType = FocusType.COMPLEX_TYPE;
private ItemPathDto parentPath;
private ItemDefinition<?> itemDef;
private ItemPath path;
public ItemPathDto() {
// TODO Auto-generated constructor stub
}
public ItemPathDto(ItemPathType itemPathType) {
if (itemPathType == null) {
return;
}
this.path = itemPathType.getItemPath();
}
public ItemPathDto(ItemPathDto parentPath) {
this.parentPath = parentPath;
this.path = parentPath.toItemPath();
}
public QName getObjectType() {
return objectType;
}
public void setObjectType(QName objectType) {
this.objectType = objectType;
}
public ItemDefinition<?> getItemDef() {
return itemDef;
}
public void setItemDef(ItemDefinition<?> itemDef) {
if (parentPath == null) {
this.path = itemDef.getItemName();
} else {
this.path = parentPath.toItemPath().append(itemDef.getItemName());
}
this.itemDef = itemDef;
}
public ItemPathDto getParentPath() {
return parentPath;
}
public void setParentPath(ItemPathDto parentPath) {
this.parentPath = parentPath;
}
public ItemPath toItemPath() {
if (parentPath == null) {
if (itemDef == null) {
return path;
}
this.path = itemDef.getItemName();
} else {
if (itemDef == null) {
return parentPath.toItemPath();
}
this.path = parentPath.toItemPath().append(itemDef.getItemName());
}
return path;
}
public boolean isPathDefined() {
return (path != null && itemDef == null && parentPath == null);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("{ObjectType: [").append("], Parent: [").append(parentPath).append("], ItemDef: [")
.append(getItemDef()).append("], Path: [").append(path).append("] }");
return sb.toString();
}
}