-
Notifications
You must be signed in to change notification settings - Fork 188
/
SceneImpl.java
239 lines (204 loc) · 5.82 KB
/
SceneImpl.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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
/*
* Copyright (c) 2010-2016 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.model.impl.visualizer.output;
import com.evolveum.midpoint.model.api.visualizer.Scene;
import com.evolveum.midpoint.prism.PrismContainerDefinition;
import com.evolveum.midpoint.prism.PrismContainerValue;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.prism.delta.ChangeType;
import com.evolveum.midpoint.prism.delta.ObjectDelta;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.util.DebugDumpable;
import com.evolveum.midpoint.util.DebugUtil;
import com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
/**
* @author mederly
*/
public class SceneImpl implements Scene, DebugDumpable {
private NameImpl name;
private ChangeType changeType;
private final List<SceneImpl> partialScenes = new ArrayList<>();
private final List<SceneItemImpl> items = new ArrayList<>();
private final SceneImpl owner;
private boolean operational;
private ItemPath sourceRelPath;
private ItemPath sourceAbsPath;
private PrismContainerValue<?> sourceValue;
private PrismContainerDefinition<?> sourceDefinition;
private ObjectDelta<?> sourceDelta;
public SceneImpl(SceneImpl owner) {
this.owner = owner;
}
@Override
public NameImpl getName() {
return name;
}
public void setName(NameImpl name) {
this.name = name;
}
@Override
public ChangeType getChangeType() {
return changeType;
}
public void setChangeType(ChangeType changeType) {
this.changeType = changeType;
}
@NotNull
@Override
public List<? extends SceneImpl> getPartialScenes() {
return partialScenes;
}
public void addPartialScene(SceneImpl subscene) {
partialScenes.add(subscene);
}
@NotNull
@Override
public List<? extends SceneItemImpl> getItems() {
return items;
}
public void addItem(SceneItemImpl item) {
items.add(item);
}
@Override
public SceneImpl getOwner() {
return owner;
}
@Override
public boolean isOperational() {
return operational;
}
public void setOperational(boolean operational) {
this.operational = operational;
}
public ItemPath getSourceRelPath() {
return sourceRelPath;
}
public void setSourceRelPath(ItemPath sourceRelPath) {
this.sourceRelPath = sourceRelPath;
}
@Override
public ItemPath getSourceAbsPath() {
return sourceAbsPath;
}
public void setSourceAbsPath(ItemPath sourceAbsPath) {
this.sourceAbsPath = sourceAbsPath;
}
@Override
public PrismContainerValue<?> getSourceValue() {
return sourceValue;
}
public void setSourceValue(PrismContainerValue<?> sourceValue) {
this.sourceValue = sourceValue;
}
@Override
public PrismContainerDefinition<?> getSourceDefinition() {
return sourceDefinition;
}
public void setSourceDefinition(PrismContainerDefinition<?> sourceDefinition) {
this.sourceDefinition = sourceDefinition;
}
@Override
public ObjectDelta<?> getSourceDelta() {
return sourceDelta;
}
public void setSourceDelta(ObjectDelta<?> sourceDelta) {
this.sourceDelta = sourceDelta;
}
@Override
public String debugDump() {
return debugDump(0);
}
@Override
public String debugDump(int indent) {
StringBuilder sb = new StringBuilder();
DebugUtil.indentDebugDump(sb, indent);
sb.append("Scene: ");
if (changeType != null) {
sb.append(changeType).append(": ");
}
if (name != null) {
sb.append(name.toDebugDump());
} else {
sb.append("(unnamed)");
}
sb.append(" [rel-path: ").append(sourceRelPath).append("]");
sb.append(" [abs-path: ").append(sourceAbsPath).append("]");
if (sourceValue != null) {
sb.append(" VAL");
}
if (sourceDefinition != null) {
sb.append(" DEF(").append(sourceDefinition.getName().getLocalPart()).append("/").append(sourceDefinition.getDisplayName()).append(")");
}
if (sourceDelta != null) {
sb.append(" DELTA");
}
if (operational) {
sb.append(" OPER");
}
for (SceneItemImpl dataItem : items) {
sb.append("\n");
sb.append(dataItem.debugDump(indent+1));
}
for (SceneImpl dataContext : partialScenes) {
sb.append("\n");
sb.append(dataContext.debugDump(indent+1));
}
return sb.toString();
}
public String getSourceOid() {
if (sourceValue != null && sourceValue.getParent() instanceof PrismObject) {
return ((PrismObject) sourceValue.getParent()).getOid();
} else {
return null;
}
}
public boolean isObjectValue() {
return sourceValue != null && sourceValue.getParent() instanceof PrismObject;
}
public boolean isContainerValue() {
return sourceValue != null && !(sourceValue.getParent() instanceof PrismObject);
}
public Long getSourceContainerValueId() {
if (isContainerValue()) {
return sourceValue.getId();
} else {
return null;
}
}
public boolean isFocusObject() {
return sourceDefinition != null && sourceDefinition.getCompileTimeClass() != null && FocusType.class.isAssignableFrom(sourceDefinition.getCompileTimeClass());
}
public boolean isEmpty() {
if (changeType != ChangeType.MODIFY) {
return false; // ADD or DELETE are never 'empty'
}
for (SceneItemImpl item : getItems()) {
if (item.isDescriptive()) {
continue;
}
return false;
}
for (SceneImpl partialScene : getPartialScenes()) {
if (!partialScene.isEmpty()) {
return false;
}
}
return true;
}
}