1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
package org.qedeq.kernel.bo.service.control; |
17 |
|
|
18 |
|
import java.util.ArrayList; |
19 |
|
import java.util.List; |
20 |
|
|
21 |
|
import org.qedeq.base.trace.Trace; |
22 |
|
import org.qedeq.base.utility.StringUtility; |
23 |
|
import org.qedeq.kernel.bo.log.ModuleEventLog; |
24 |
|
import org.qedeq.kernel.bo.module.InternalPluginBo; |
25 |
|
import org.qedeq.kernel.bo.module.KernelModuleReferenceList; |
26 |
|
import org.qedeq.kernel.bo.module.ModuleConstantsExistenceChecker; |
27 |
|
import org.qedeq.kernel.bo.module.ModuleLabels; |
28 |
|
import org.qedeq.kernel.se.common.ModuleDataException; |
29 |
|
import org.qedeq.kernel.se.common.Plugin; |
30 |
|
import org.qedeq.kernel.se.common.SourceFileExceptionList; |
31 |
|
import org.qedeq.kernel.se.dto.module.QedeqVo; |
32 |
|
import org.qedeq.kernel.se.state.AbstractState; |
33 |
|
import org.qedeq.kernel.se.state.DependencyState; |
34 |
|
import org.qedeq.kernel.se.state.FormallyProvedState; |
35 |
|
import org.qedeq.kernel.se.state.LoadingImportsState; |
36 |
|
import org.qedeq.kernel.se.state.LoadingState; |
37 |
|
import org.qedeq.kernel.se.state.WellFormedState; |
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
@link |
42 |
|
|
43 |
|
|
44 |
|
@author |
45 |
|
|
|
|
| 70.2% |
Uncovered Elements: 150 (503) |
Complexity: 129 |
Complexity Density: 0.41 |
|
46 |
|
public class StateManager { |
47 |
|
|
48 |
|
|
49 |
|
private static final Class CLASS = StateManager.class; |
50 |
|
|
51 |
|
|
52 |
|
private final DefaultKernelQedeqBo bo; |
53 |
|
|
54 |
|
|
55 |
|
private int loadingCompleteness; |
56 |
|
|
57 |
|
|
58 |
|
private LoadingState loadingState; |
59 |
|
|
60 |
|
|
61 |
|
private LoadingImportsState loadingImportsState; |
62 |
|
|
63 |
|
|
64 |
|
private DependencyState dependencyState; |
65 |
|
|
66 |
|
|
67 |
|
private WellFormedState wellFormedState; |
68 |
|
|
69 |
|
|
70 |
|
private FormallyProvedState formallyProvedState; |
71 |
|
|
72 |
|
|
73 |
|
private PluginResultManager pluginResults; |
74 |
|
|
75 |
|
|
76 |
|
private SourceFileExceptionList errors; |
77 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
|
78 |
609
|
StateManager(final DefaultKernelQedeqBo bo) {... |
79 |
609
|
this.bo = bo; |
80 |
609
|
loadingState = LoadingState.STATE_UNDEFINED; |
81 |
609
|
loadingCompleteness = 0; |
82 |
609
|
loadingImportsState = LoadingImportsState.STATE_UNDEFINED; |
83 |
609
|
dependencyState = DependencyState.STATE_UNDEFINED; |
84 |
609
|
wellFormedState = WellFormedState.STATE_UNCHECKED; |
85 |
609
|
formallyProvedState = FormallyProvedState.STATE_UNCHECKED; |
86 |
609
|
pluginResults = new PluginResultManager(); |
87 |
|
} |
88 |
|
|
89 |
|
|
90 |
|
|
91 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (12) |
Complexity: 1 |
Complexity Density: 0.08 |
|
92 |
603
|
public void delete() {... |
93 |
603
|
checkIfDeleted(); |
94 |
603
|
invalidateOtherDependentModulesToLoaded(); |
95 |
603
|
setLoadingState(LoadingState.STATE_DELETED); |
96 |
603
|
bo.setQedeqVo(null); |
97 |
603
|
bo.getKernelRequiredModules().clear(); |
98 |
603
|
bo.getDependentModules().clear(); |
99 |
603
|
bo.setLabels(null); |
100 |
603
|
setDependencyState(DependencyState.STATE_UNDEFINED); |
101 |
603
|
setWellFormedState(WellFormedState.STATE_UNCHECKED); |
102 |
603
|
setFormallyProvedState(FormallyProvedState.STATE_UNCHECKED); |
103 |
603
|
setErrors(null); |
104 |
603
|
ModuleEventLog.getInstance().removeModule(bo); |
105 |
|
} |
106 |
|
|
107 |
|
|
108 |
|
|
109 |
|
|
110 |
|
|
111 |
|
@return |
112 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
113 |
798
|
public boolean hasBasicFailures() {... |
114 |
798
|
return loadingState.isFailure() || dependencyState.isFailure() |
115 |
|
|| wellFormedState.isFailure() || formallyProvedState.isFailure(); |
116 |
|
} |
117 |
|
|
118 |
|
|
119 |
|
|
120 |
|
|
121 |
|
@return |
122 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
123 |
420
|
public boolean hasErrors() {... |
124 |
420
|
return hasBasicFailures() || (getErrors() != null && getErrors().size() > 0); |
125 |
|
} |
126 |
|
|
127 |
|
|
128 |
|
|
129 |
|
|
130 |
|
@return |
131 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
132 |
58
|
public boolean hasWarnings() {... |
133 |
58
|
return (getWarnings() != null && getWarnings().size() > 0); |
134 |
|
} |
135 |
|
|
136 |
|
|
137 |
|
|
138 |
|
|
139 |
|
@param |
140 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
141 |
0
|
public void setLoadingCompleteness(final int completeness) {... |
142 |
0
|
this.loadingCompleteness = completeness; |
143 |
|
} |
144 |
|
|
145 |
|
|
146 |
|
|
147 |
|
|
148 |
|
@return |
149 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
150 |
0
|
public int getLoadingCompleteness() {... |
151 |
0
|
return this.loadingCompleteness; |
152 |
|
} |
153 |
|
|
154 |
|
|
155 |
|
|
156 |
|
|
157 |
|
@return |
158 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
159 |
5675
|
public LoadingState getLoadingState() {... |
160 |
5675
|
return this.loadingState; |
161 |
|
} |
162 |
|
|
163 |
|
|
164 |
|
|
165 |
|
|
166 |
|
@return |
167 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
168 |
9011
|
public boolean isLoaded() {... |
169 |
9011
|
return loadingState == LoadingState.STATE_LOADED; |
170 |
|
} |
171 |
|
|
172 |
|
|
173 |
|
|
174 |
|
|
175 |
|
@param |
176 |
|
@throws |
177 |
|
|
|
|
| 92.9% |
Uncovered Elements: 2 (28) |
Complexity: 6 |
Complexity Density: 0.3 |
|
178 |
1178
|
public void setLoadingProgressState(final LoadingState state) {... |
179 |
1178
|
checkIfDeleted(); |
180 |
1178
|
if (state == LoadingState.STATE_LOADED) { |
181 |
1
|
throw new IllegalArgumentException( |
182 |
|
"this state could only be set by calling method setLoaded"); |
183 |
|
} |
184 |
1176
|
if (state != LoadingState.STATE_DELETED && state.isFailure()) { |
185 |
3
|
throw new IllegalArgumentException( |
186 |
|
"this is a failure state, call setLoadingFailureState for " + state); |
187 |
|
} |
188 |
|
|
189 |
1173
|
if (getLoadingState() == LoadingState.STATE_UNDEFINED) { |
190 |
594
|
setLoadingState(state); |
191 |
594
|
ModuleEventLog.getInstance().addModule(bo); |
192 |
|
} |
193 |
1173
|
if (state == LoadingState.STATE_DELETED) { |
194 |
0
|
throw new IllegalArgumentException( |
195 |
|
"call delete for " + state); |
196 |
|
} |
197 |
1173
|
setLoadingState(state); |
198 |
1173
|
bo.setQedeqVo(null); |
199 |
1173
|
bo.getKernelRequiredModules().clear(); |
200 |
1173
|
bo.getDependentModules().clear(); |
201 |
1173
|
bo.setLabels(null); |
202 |
1173
|
setLoadingImportsState(LoadingImportsState.STATE_UNDEFINED); |
203 |
1173
|
setDependencyState(DependencyState.STATE_UNDEFINED); |
204 |
1173
|
setWellFormedState(WellFormedState.STATE_UNCHECKED); |
205 |
1173
|
setErrors(null); |
206 |
1173
|
ModuleEventLog.getInstance().stateChanged(bo); |
207 |
|
} |
208 |
|
|
209 |
|
|
210 |
|
|
211 |
|
|
212 |
|
@param |
213 |
|
@param |
214 |
|
@throws |
215 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (25) |
Complexity: 4 |
Complexity Density: 0.21 |
|
216 |
62
|
public void setLoadingFailureState(final LoadingState state,... |
217 |
|
final SourceFileExceptionList e) { |
218 |
62
|
if (e == null) { |
219 |
1
|
throw new NullPointerException("Exception must not be null"); |
220 |
|
} |
221 |
61
|
checkIfDeleted(); |
222 |
59
|
if (!state.isFailure()) { |
223 |
6
|
throw new IllegalArgumentException( |
224 |
|
"this is no failure state, call setLoadingProgressState"); |
225 |
|
} |
226 |
|
|
227 |
53
|
if (getLoadingState() == LoadingState.STATE_UNDEFINED) { |
228 |
3
|
setLoadingState(state); |
229 |
3
|
ModuleEventLog.getInstance().addModule(bo); |
230 |
|
} |
231 |
53
|
bo.setQedeqVo(null); |
232 |
53
|
bo.getKernelRequiredModules().clear(); |
233 |
53
|
bo.getDependentModules().clear(); |
234 |
53
|
bo.setLabels(null); |
235 |
53
|
setLoadingState(state); |
236 |
53
|
setLoadingImportsState(LoadingImportsState.STATE_UNDEFINED); |
237 |
53
|
setDependencyState(DependencyState.STATE_UNDEFINED); |
238 |
53
|
setWellFormedState(WellFormedState.STATE_UNCHECKED); |
239 |
53
|
setFormallyProvedState(FormallyProvedState.STATE_UNCHECKED); |
240 |
53
|
setErrors(e); |
241 |
53
|
ModuleEventLog.getInstance().stateChanged(bo); |
242 |
|
} |
243 |
|
|
244 |
|
|
245 |
|
|
246 |
|
@link |
247 |
|
|
248 |
|
@param |
249 |
|
@param |
250 |
|
@throws |
251 |
|
|
|
|
| 87.5% |
Uncovered Elements: 2 (16) |
Complexity: 2 |
Complexity Density: 0.14 |
|
252 |
583
|
public void setLoaded(final QedeqVo qedeq, final ModuleLabels labels) {... |
253 |
583
|
checkIfDeleted(); |
254 |
583
|
if (qedeq == null) { |
255 |
0
|
throw new NullPointerException("Qedeq is null"); |
256 |
|
} |
257 |
583
|
setLoadingState(LoadingState.STATE_LOADED); |
258 |
583
|
setLoadingImportsState(LoadingImportsState.STATE_UNDEFINED); |
259 |
583
|
setDependencyState(DependencyState.STATE_UNDEFINED); |
260 |
583
|
setWellFormedState(WellFormedState.STATE_UNCHECKED); |
261 |
583
|
setFormallyProvedState(FormallyProvedState.STATE_UNCHECKED); |
262 |
583
|
setErrors(null); |
263 |
583
|
bo.setQedeqVo(qedeq); |
264 |
583
|
bo.getKernelRequiredModules().clear(); |
265 |
583
|
bo.getDependentModules().clear(); |
266 |
583
|
bo.setLabels(labels); |
267 |
583
|
ModuleEventLog.getInstance().stateChanged(bo); |
268 |
|
} |
269 |
|
|
270 |
|
|
271 |
|
|
272 |
|
|
273 |
|
@param |
274 |
|
@throws |
275 |
|
@throws |
276 |
|
|
277 |
|
@throws |
278 |
|
|
|
|
| 0% |
Uncovered Elements: 14 (14) |
Complexity: 5 |
Complexity Density: 0.62 |
|
279 |
0
|
public void setLoadingImportsProgressState(final LoadingImportsState state) {... |
280 |
0
|
checkIfDeleted(); |
281 |
0
|
if (!isLoaded() && state != LoadingImportsState.STATE_UNDEFINED) { |
282 |
0
|
throw new IllegalStateException("module is not yet loaded"); |
283 |
|
} |
284 |
0
|
if (state.isFailure()) { |
285 |
0
|
throw new IllegalArgumentException( |
286 |
|
"this is a failure state, call setLoadingImportsFailureState"); |
287 |
|
} |
288 |
0
|
if (state == LoadingImportsState.STATE_LOADED_IMPORTED_MODULES) { |
289 |
0
|
throw new IllegalArgumentException( |
290 |
|
"this state could only be set by calling method setLoadedImports"); |
291 |
|
} |
292 |
0
|
ModuleEventLog.getInstance().stateChanged(bo); |
293 |
|
} |
294 |
|
|
295 |
|
|
296 |
|
|
297 |
|
|
298 |
|
@param |
299 |
|
@param |
300 |
|
@throws |
301 |
|
@throws |
302 |
|
@throws |
303 |
|
|
|
|
| 62.5% |
Uncovered Elements: 6 (16) |
Complexity: 4 |
Complexity Density: 0.4 |
|
304 |
1
|
public void setLoadingImportsFailureState(final LoadingImportsState state,... |
305 |
|
final SourceFileExceptionList e) { |
306 |
1
|
if (e == null) { |
307 |
0
|
throw new NullPointerException("Exception must not be null"); |
308 |
|
} |
309 |
1
|
checkIfDeleted(); |
310 |
1
|
if (!isLoaded()) { |
311 |
0
|
throw new IllegalStateException("module is not yet loaded"); |
312 |
|
} |
313 |
1
|
if (!state.isFailure()) { |
314 |
0
|
throw new IllegalArgumentException( |
315 |
|
"this is no failure state, call setLoadingProgressState"); |
316 |
|
} |
317 |
1
|
setLoadingImportsState(state); |
318 |
1
|
setErrors(e); |
319 |
1
|
ModuleEventLog.getInstance().stateChanged(bo); |
320 |
|
} |
321 |
|
|
322 |
|
|
323 |
|
|
324 |
|
|
325 |
|
@return |
326 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
327 |
0
|
public LoadingImportsState getLoadingImportsState() {... |
328 |
0
|
return this.loadingImportsState; |
329 |
|
} |
330 |
|
|
331 |
|
|
332 |
|
|
333 |
|
|
334 |
|
@return |
335 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
336 |
1436
|
public boolean hasLoadedImports() {... |
337 |
1436
|
return loadingImportsState == LoadingImportsState.STATE_LOADED_IMPORTED_MODULES; |
338 |
|
} |
339 |
|
|
340 |
|
|
341 |
|
|
342 |
|
|
343 |
|
@param |
344 |
|
@throws |
345 |
|
@throws |
346 |
|
|
347 |
|
@throws |
348 |
|
|
|
|
| 66.7% |
Uncovered Elements: 6 (18) |
Complexity: 5 |
Complexity Density: 0.42 |
|
349 |
378
|
public void setDependencyProgressState(final DependencyState state) {... |
350 |
378
|
checkIfDeleted(); |
351 |
378
|
if (!isLoaded() && state != DependencyState.STATE_UNDEFINED) { |
352 |
0
|
throw new IllegalStateException("module is not yet loaded"); |
353 |
|
} |
354 |
378
|
if (state.isFailure()) { |
355 |
0
|
throw new IllegalArgumentException( |
356 |
|
"this is a failure state, call setDependencyFailureState"); |
357 |
|
} |
358 |
378
|
if (state == DependencyState.STATE_LOADED_REQUIRED_MODULES) { |
359 |
0
|
throw new IllegalArgumentException( |
360 |
|
"this state could only be set by calling method setLoadedRequiredModules"); |
361 |
|
} |
362 |
378
|
setWellFormedState(WellFormedState.STATE_UNCHECKED); |
363 |
378
|
setFormallyProvedState(FormallyProvedState.STATE_UNCHECKED); |
364 |
378
|
setDependencyState(state); |
365 |
378
|
setErrors(null); |
366 |
378
|
ModuleEventLog.getInstance().stateChanged(bo); |
367 |
|
} |
368 |
|
|
369 |
|
|
370 |
|
|
371 |
|
|
372 |
|
@param |
373 |
|
@param |
374 |
|
@throws |
375 |
|
@throws |
376 |
|
@throws |
377 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (16) |
Complexity: 4 |
Complexity Density: 0.4 |
|
378 |
62
|
public void setDependencyFailureState(final DependencyState state,... |
379 |
|
final SourceFileExceptionList e) { |
380 |
62
|
if (e == null) { |
381 |
1
|
throw new NullPointerException("Exception must not be null"); |
382 |
|
} |
383 |
61
|
checkIfDeleted(); |
384 |
61
|
if (!isLoaded()) { |
385 |
2
|
throw new IllegalStateException("module is not yet loaded"); |
386 |
|
} |
387 |
59
|
if (!state.isFailure()) { |
388 |
4
|
throw new IllegalArgumentException( |
389 |
|
"this is no failure state, call setLoadingProgressState"); |
390 |
|
} |
391 |
55
|
setDependencyState(state); |
392 |
55
|
setErrors(e); |
393 |
55
|
ModuleEventLog.getInstance().stateChanged(bo); |
394 |
|
} |
395 |
|
|
396 |
|
|
397 |
|
|
398 |
|
|
399 |
|
@return |
400 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
401 |
1023
|
public DependencyState getDependencyState() {... |
402 |
1023
|
return this.dependencyState; |
403 |
|
} |
404 |
|
|
405 |
|
|
406 |
|
|
407 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (35) |
Complexity: 6 |
Complexity Density: 0.24 |
|
408 |
721
|
private void invalidateOtherDependentModulesToLoaded() {... |
409 |
721
|
final String method = "invalidateOtherDependModulesToLoaded"; |
410 |
721
|
Trace.begin(CLASS, this, method); |
411 |
721
|
Trace.param(CLASS, this, method, "bo", bo); |
412 |
721
|
if (hasLoadedRequiredModules()) { |
413 |
319
|
final KernelModuleReferenceList dependent = bo.getDependentModules(); |
414 |
319
|
Trace.trace(CLASS, this, method, "begin list of dependent modules"); |
415 |
|
|
416 |
319
|
final List list = new ArrayList(); |
417 |
459
|
for (int i = 0; i < dependent.size(); i++) { |
418 |
140
|
Trace.param(CLASS, this, method, "" + i, dependent.getKernelQedeqBo(i)); |
419 |
140
|
list.add(dependent.getKernelQedeqBo(i)); |
420 |
|
} |
421 |
319
|
Trace.trace(CLASS, this, method, "end list of dependent modules"); |
422 |
459
|
for (int i = 0; i < list.size(); i++) { |
423 |
140
|
DefaultKernelQedeqBo ref = (DefaultKernelQedeqBo) list.get(i); |
424 |
|
|
425 |
140
|
if (dependent.contains(ref)) { |
426 |
118
|
ref.getStateManager().invalidateDependentModulesToLoaded(); |
427 |
|
} |
428 |
|
} |
429 |
319
|
list.clear(); |
430 |
319
|
dependent.clear(); |
431 |
|
|
432 |
319
|
final KernelModuleReferenceList required = bo.getKernelRequiredModules(); |
433 |
506
|
for (int i = 0; i < required.size(); i++) { |
434 |
187
|
DefaultKernelQedeqBo ref = (DefaultKernelQedeqBo) required.getKernelQedeqBo(i); |
435 |
187
|
Trace.param(CLASS, this, method, "remove dependence from", ref); |
436 |
187
|
ref.getDependentModules().remove(bo); |
437 |
|
} |
438 |
319
|
required.clear(); |
439 |
319
|
bo.getLabels().resetNodesToWellFormedUnchecked(); |
440 |
|
} |
441 |
721
|
Trace.end(CLASS, this, method); |
442 |
|
} |
443 |
|
|
444 |
|
|
445 |
|
|
446 |
|
|
|
|
| 90.9% |
Uncovered Elements: 1 (11) |
Complexity: 2 |
Complexity Density: 0.22 |
|
447 |
118
|
private void invalidateDependentModulesToLoaded() {... |
448 |
118
|
final String method = "invalidateDependentModulesToLoaded"; |
449 |
118
|
Trace.begin(CLASS, this, method); |
450 |
118
|
Trace.param(CLASS, this, method, "bo", bo); |
451 |
118
|
if (hasLoadedRequiredModules()) { |
452 |
118
|
invalidateOtherDependentModulesToLoaded(); |
453 |
118
|
invalidateThisModuleToLoaded(); |
454 |
118
|
setLoadingState(LoadingState.STATE_LOADED); |
455 |
118
|
ModuleEventLog.getInstance().stateChanged(bo); |
456 |
|
} |
457 |
118
|
Trace.end(CLASS, this, method); |
458 |
|
} |
459 |
|
|
460 |
|
|
461 |
|
|
462 |
|
|
463 |
|
|
464 |
|
|
465 |
|
|
466 |
|
|
467 |
|
|
468 |
|
|
469 |
|
|
470 |
|
|
471 |
|
|
472 |
|
|
473 |
|
|
474 |
|
|
475 |
|
|
476 |
|
|
477 |
|
|
478 |
|
|
479 |
|
|
480 |
|
|
481 |
|
|
482 |
|
|
483 |
|
|
484 |
|
|
485 |
|
|
486 |
|
|
487 |
|
|
488 |
|
|
489 |
|
|
490 |
|
|
491 |
|
|
492 |
|
|
493 |
|
|
494 |
|
|
495 |
|
|
496 |
|
|
497 |
|
|
498 |
|
|
499 |
|
|
500 |
|
|
501 |
|
|
502 |
|
|
503 |
|
|
504 |
|
|
505 |
|
|
506 |
|
|
507 |
|
|
508 |
|
|
509 |
|
|
510 |
|
|
511 |
|
|
512 |
|
|
513 |
|
|
514 |
|
|
515 |
|
|
516 |
|
|
517 |
|
|
518 |
|
|
519 |
|
|
520 |
|
|
521 |
|
|
522 |
|
|
523 |
|
|
524 |
|
|
525 |
|
|
526 |
|
|
527 |
|
|
528 |
|
|
529 |
|
|
530 |
|
|
531 |
|
|
532 |
|
|
533 |
|
|
534 |
|
|
535 |
|
|
536 |
|
|
537 |
|
|
538 |
|
|
539 |
|
|
540 |
|
|
541 |
|
|
542 |
|
|
543 |
|
|
544 |
|
|
545 |
|
|
546 |
|
|
547 |
|
|
|
|
| 90% |
Uncovered Elements: 1 (10) |
Complexity: 2 |
Complexity Density: 0.25 |
|
548 |
118
|
private void invalidateThisModuleToLoaded() {... |
549 |
118
|
if (isLoaded()) { |
550 |
118
|
setLoadingState(LoadingState.STATE_LOADED); |
551 |
118
|
setLoadingImportsState(LoadingImportsState.STATE_UNDEFINED); |
552 |
118
|
setDependencyState(DependencyState.STATE_UNDEFINED); |
553 |
118
|
setWellFormedState(WellFormedState.STATE_UNCHECKED); |
554 |
118
|
setFormallyProvedState(FormallyProvedState.STATE_UNCHECKED); |
555 |
118
|
bo.getKernelRequiredModules().clear(); |
556 |
118
|
setErrors(null); |
557 |
|
} |
558 |
|
} |
559 |
|
|
560 |
|
|
561 |
|
|
562 |
|
|
563 |
|
|
564 |
|
|
565 |
|
|
566 |
|
|
567 |
|
|
568 |
|
|
569 |
|
|
570 |
|
|
571 |
|
|
572 |
|
|
573 |
|
|
574 |
|
|
575 |
|
|
576 |
|
|
577 |
|
|
578 |
|
|
579 |
|
|
580 |
|
|
581 |
|
|
582 |
|
|
583 |
|
|
584 |
|
|
585 |
|
|
586 |
|
|
587 |
|
|
588 |
|
|
589 |
|
|
590 |
|
|
591 |
|
|
592 |
|
|
593 |
|
|
594 |
|
|
595 |
|
|
596 |
|
|
597 |
|
@return |
598 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
599 |
5930
|
public boolean hasLoadedRequiredModules() {... |
600 |
5930
|
return isLoaded() && dependencyState == DependencyState.STATE_LOADED_REQUIRED_MODULES; |
601 |
|
} |
602 |
|
|
603 |
|
|
604 |
|
|
605 |
|
|
606 |
|
@param |
607 |
|
@throws |
608 |
|
|
|
|
| 81.8% |
Uncovered Elements: 2 (11) |
Complexity: 2 |
Complexity Density: 0.22 |
|
609 |
353
|
public void setLoadedImports(final KernelModuleReferenceList required) {... |
610 |
353
|
checkIfDeleted(); |
611 |
353
|
if (!isLoaded()) { |
612 |
0
|
throw new IllegalStateException( |
613 |
|
"Loaded imported modules can only be set if module is loaded." |
614 |
|
+ "\"\nCurrently the status for the module" |
615 |
|
+ "\"" + bo.getName() + "\" is \"" + bo.getLoadingState() + "\""); |
616 |
|
} |
617 |
353
|
setLoadingImportsState(LoadingImportsState.STATE_LOADED_IMPORTED_MODULES); |
618 |
353
|
setDependencyState(DependencyState.STATE_UNDEFINED); |
619 |
353
|
setWellFormedState(WellFormedState.STATE_UNCHECKED); |
620 |
353
|
setErrors(null); |
621 |
353
|
bo.getKernelRequiredModules().set(required); |
622 |
353
|
ModuleEventLog.getInstance().stateChanged(bo); |
623 |
|
} |
624 |
|
|
625 |
|
|
626 |
|
|
627 |
|
|
628 |
|
@throws |
629 |
|
|
|
|
| 82.4% |
Uncovered Elements: 3 (17) |
Complexity: 4 |
Complexity Density: 0.31 |
|
630 |
331
|
public void setLoadedRequiredModules() {... |
631 |
331
|
checkIfDeleted(); |
632 |
331
|
if (!isLoaded()) { |
633 |
0
|
throw new IllegalStateException( |
634 |
|
"Required modules can only be set if module is loaded." |
635 |
|
+ "\"\nCurrently the status for the module" |
636 |
|
+ "\"" + bo.getName() + "\" is \"" + bo.getLoadingState() + "\""); |
637 |
|
} |
638 |
331
|
KernelModuleReferenceList required = bo.getKernelRequiredModules(); |
639 |
524
|
for (int i = 0; i < required.size(); i++) { |
640 |
193
|
DefaultKernelQedeqBo current = (DefaultKernelQedeqBo) required.getKernelQedeqBo(i); |
641 |
193
|
try { |
642 |
193
|
current.getDependentModules().add(required.getModuleContext(i), |
643 |
|
required.getLabel(i), bo); |
644 |
|
} catch (ModuleDataException me) { |
645 |
0
|
throw new RuntimeException(me); |
646 |
|
} |
647 |
|
} |
648 |
331
|
setDependencyState(DependencyState.STATE_LOADED_REQUIRED_MODULES); |
649 |
331
|
setWellFormedState(WellFormedState.STATE_UNCHECKED); |
650 |
331
|
setErrors(null); |
651 |
331
|
ModuleEventLog.getInstance().stateChanged(bo); |
652 |
|
} |
653 |
|
|
654 |
|
|
655 |
|
|
656 |
|
|
657 |
|
@param |
658 |
|
|
|
|
| 75% |
Uncovered Elements: 2 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
659 |
279
|
public void setWellFormed(final ModuleConstantsExistenceChecker checker) {... |
660 |
279
|
checkIfDeleted(); |
661 |
279
|
if (!hasLoadedRequiredModules()) { |
662 |
0
|
throw new IllegalStateException( |
663 |
|
"Checked can only be set if all required modules are loaded." |
664 |
|
+ "\"\nCurrently the status for the module" |
665 |
|
+ "\"" + bo.getName() + "\" is \"" + bo.getLoadingState() + "\""); |
666 |
|
} |
667 |
279
|
setWellFormedState(WellFormedState.STATE_CHECKED); |
668 |
279
|
bo.setExistenceChecker(checker); |
669 |
279
|
ModuleEventLog.getInstance().stateChanged(bo); |
670 |
|
} |
671 |
|
|
672 |
|
|
673 |
|
|
674 |
|
|
675 |
|
@param |
676 |
|
|
|
|
| 60% |
Uncovered Elements: 6 (15) |
Complexity: 5 |
Complexity Density: 0.56 |
|
677 |
616
|
public void setWellFormedProgressState(final WellFormedState state) {... |
678 |
616
|
if (getDependencyState().getCode() |
679 |
|
< DependencyState.STATE_LOADED_REQUIRED_MODULES.getCode() |
680 |
|
&& state != WellFormedState.STATE_UNCHECKED) { |
681 |
0
|
throw new IllegalArgumentException( |
682 |
|
"this state could only be set if all required modules are loaded "); |
683 |
|
} |
684 |
616
|
if (state.isFailure()) { |
685 |
0
|
throw new IllegalArgumentException( |
686 |
|
"this is a failure state, call setWellFormedFailureState"); |
687 |
|
} |
688 |
616
|
if (state == WellFormedState.STATE_CHECKED) { |
689 |
0
|
throw new IllegalArgumentException( |
690 |
|
"set with setChecked(ExistenceChecker)"); |
691 |
|
} |
692 |
616
|
setWellFormedState(state); |
693 |
616
|
setErrors(null); |
694 |
616
|
ModuleEventLog.getInstance().stateChanged(bo); |
695 |
|
} |
696 |
|
|
697 |
|
|
698 |
|
|
699 |
|
|
700 |
|
@param |
701 |
|
@param |
702 |
|
@throws |
703 |
|
|
|
|
| 63.6% |
Uncovered Elements: 4 (11) |
Complexity: 5 |
Complexity Density: 0.71 |
|
704 |
34
|
public void setWellFormedFailureState(final WellFormedState state,... |
705 |
|
final SourceFileExceptionList e) { |
706 |
34
|
if ((!isLoaded() || !hasLoadedRequiredModules()) |
707 |
|
&& state != WellFormedState.STATE_UNCHECKED) { |
708 |
0
|
throw new IllegalArgumentException( |
709 |
|
"this state could only be set if all required modules are loaded "); |
710 |
|
} |
711 |
34
|
if (!state.isFailure()) { |
712 |
0
|
throw new IllegalArgumentException( |
713 |
|
"this is no failure state, call setWellFormedProgressState"); |
714 |
|
} |
715 |
34
|
setWellFormedState(state); |
716 |
34
|
setErrors(e); |
717 |
34
|
ModuleEventLog.getInstance().stateChanged(bo); |
718 |
|
} |
719 |
|
|
720 |
|
|
721 |
|
|
722 |
|
|
723 |
|
@param |
724 |
|
|
|
|
| 63.6% |
Uncovered Elements: 4 (11) |
Complexity: 4 |
Complexity Density: 0.57 |
|
725 |
25
|
public void setFormallyProvedProgressState(final FormallyProvedState state) {... |
726 |
25
|
if (getDependencyState().getCode() |
727 |
|
< DependencyState.STATE_LOADED_REQUIRED_MODULES.getCode() |
728 |
|
&& state != FormallyProvedState.STATE_UNCHECKED) { |
729 |
0
|
throw new IllegalArgumentException( |
730 |
|
"this state could only be set if all required modules are loaded "); |
731 |
|
} |
732 |
25
|
if (state.isFailure()) { |
733 |
0
|
throw new IllegalArgumentException( |
734 |
|
"this is a failure state, call setFormallyProvedFailureState"); |
735 |
|
} |
736 |
|
|
737 |
|
|
738 |
|
|
739 |
|
|
740 |
|
|
741 |
25
|
setFormallyProvedState(state); |
742 |
25
|
setErrors(null); |
743 |
25
|
ModuleEventLog.getInstance().stateChanged(bo); |
744 |
|
} |
745 |
|
|
746 |
|
|
747 |
|
|
748 |
|
|
749 |
|
@param |
750 |
|
@param |
751 |
|
@throws |
752 |
|
|
|
|
| 63.6% |
Uncovered Elements: 4 (11) |
Complexity: 5 |
Complexity Density: 0.71 |
|
753 |
5
|
public void setFormallyProvedFailureState(final FormallyProvedState state,... |
754 |
|
final SourceFileExceptionList e) { |
755 |
5
|
if ((!isLoaded() || !hasLoadedRequiredModules()) |
756 |
|
&& state != FormallyProvedState.STATE_UNCHECKED) { |
757 |
0
|
throw new IllegalArgumentException( |
758 |
|
"this state could only be set if all required modules are well formed "); |
759 |
|
} |
760 |
5
|
if (!state.isFailure()) { |
761 |
0
|
throw new IllegalArgumentException( |
762 |
|
"this is no failure state, call setFormallyProvedProgressState"); |
763 |
|
} |
764 |
5
|
setFormallyProvedState(state); |
765 |
5
|
setErrors(e); |
766 |
5
|
ModuleEventLog.getInstance().stateChanged(bo); |
767 |
|
} |
768 |
|
|
769 |
|
|
770 |
|
|
771 |
|
|
772 |
|
@throws |
773 |
|
|
|
|
| 50% |
Uncovered Elements: 2 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
774 |
3828
|
private void checkIfDeleted() {... |
775 |
3828
|
if (getLoadingState() == LoadingState.STATE_DELETED) { |
776 |
0
|
throw new IllegalStateException("module is already deleted: " + bo.getUrl()); |
777 |
|
} |
778 |
|
} |
779 |
|
|
780 |
|
|
781 |
|
|
782 |
|
|
783 |
|
@return |
784 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
785 |
1380
|
public boolean isWellFormed() {... |
786 |
1380
|
return hasLoadedRequiredModules() && wellFormedState == WellFormedState.STATE_CHECKED; |
787 |
|
} |
788 |
|
|
789 |
|
|
790 |
|
|
791 |
|
|
792 |
|
@return |
793 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
794 |
8
|
public WellFormedState getWellFormedState() {... |
795 |
8
|
return this.wellFormedState; |
796 |
|
} |
797 |
|
|
798 |
|
|
799 |
|
|
800 |
|
|
801 |
|
@return |
802 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
803 |
51
|
public boolean isFullyFormallyProved() {... |
804 |
51
|
return isWellFormed() && formallyProvedState == FormallyProvedState.STATE_CHECKED; |
805 |
|
} |
806 |
|
|
807 |
|
|
808 |
|
|
809 |
|
|
810 |
|
@return |
811 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
812 |
0
|
public FormallyProvedState getFormallyProvedState() {... |
813 |
0
|
return this.formallyProvedState; |
814 |
|
} |
815 |
|
|
816 |
|
|
817 |
|
|
818 |
|
|
819 |
|
@return |
820 |
|
|
|
|
| 91.7% |
Uncovered Elements: 4 (48) |
Complexity: 12 |
Complexity Density: 0.46 |
|
821 |
57
|
public String getStateDescription() {... |
822 |
57
|
String result = ""; |
823 |
57
|
if (loadingState == LoadingState.STATE_LOADING_FROM_WEB) { |
824 |
0
|
result = loadingState.getText() + " (" + loadingCompleteness + "%)"; |
825 |
57
|
} else if (!isLoaded()) { |
826 |
6
|
result = loadingState.getText(); |
827 |
51
|
} else if (!hasLoadedImports()) { |
828 |
3
|
if (loadingImportsState == LoadingImportsState.STATE_UNDEFINED) { |
829 |
3
|
result = loadingState.getText(); |
830 |
|
} else { |
831 |
0
|
result = loadingImportsState.getText(); |
832 |
|
} |
833 |
48
|
} else if (!hasLoadedRequiredModules()) { |
834 |
6
|
if (dependencyState == DependencyState.STATE_UNDEFINED) { |
835 |
3
|
result = loadingImportsState.getText(); |
836 |
|
} else { |
837 |
3
|
result = dependencyState.getText(); |
838 |
|
} |
839 |
42
|
} else if (!isWellFormed()) { |
840 |
18
|
if (wellFormedState == WellFormedState.STATE_UNCHECKED) { |
841 |
6
|
result = dependencyState.getText(); |
842 |
|
} else { |
843 |
12
|
result = wellFormedState.getText(); |
844 |
|
} |
845 |
24
|
} else if (!isFullyFormallyProved()) { |
846 |
21
|
if (formallyProvedState == FormallyProvedState.STATE_UNCHECKED) { |
847 |
3
|
result = wellFormedState.getText(); |
848 |
|
} else { |
849 |
18
|
result = formallyProvedState.getText(); |
850 |
|
} |
851 |
|
} else { |
852 |
3
|
result = formallyProvedState.getText(); |
853 |
|
} |
854 |
57
|
final String pluginState = pluginResults.getPluginStateDescription(); |
855 |
57
|
if (pluginState.length() > 0) { |
856 |
3
|
result += "; " + pluginState; |
857 |
|
} |
858 |
57
|
return result; |
859 |
|
} |
860 |
|
|
861 |
|
|
862 |
|
|
863 |
|
|
864 |
|
@return |
865 |
|
|
|
|
| 0% |
Uncovered Elements: 37 (37) |
Complexity: 10 |
Complexity Density: 0.53 |
|
866 |
0
|
public AbstractState getCurrentState() {... |
867 |
0
|
if (!isLoaded()) { |
868 |
0
|
return loadingState; |
869 |
0
|
} else if (!hasLoadedImports()) { |
870 |
0
|
if (loadingImportsState == LoadingImportsState.STATE_UNDEFINED) { |
871 |
0
|
return loadingState; |
872 |
|
} |
873 |
0
|
return loadingImportsState; |
874 |
0
|
} else if (!hasLoadedRequiredModules()) { |
875 |
0
|
if (dependencyState == DependencyState.STATE_UNDEFINED) { |
876 |
0
|
return loadingImportsState; |
877 |
|
} |
878 |
0
|
return dependencyState; |
879 |
0
|
} else if (!isWellFormed()) { |
880 |
0
|
if (wellFormedState == WellFormedState.STATE_UNCHECKED) { |
881 |
0
|
return dependencyState; |
882 |
|
} |
883 |
0
|
return wellFormedState; |
884 |
0
|
} else if (!isFullyFormallyProved()) { |
885 |
0
|
if (formallyProvedState == FormallyProvedState.STATE_UNCHECKED) { |
886 |
0
|
return wellFormedState; |
887 |
|
} |
888 |
0
|
return formallyProvedState; |
889 |
|
} else { |
890 |
0
|
return formallyProvedState; |
891 |
|
} |
892 |
|
} |
893 |
|
|
894 |
|
|
895 |
|
|
896 |
|
|
897 |
|
|
898 |
|
@return |
899 |
|
|
|
|
| 0% |
Uncovered Elements: 21 (21) |
Complexity: 6 |
Complexity Density: 0.55 |
|
900 |
0
|
public AbstractState getLastSuccesfulState() {... |
901 |
0
|
if (!isLoaded()) { |
902 |
0
|
return LoadingState.STATE_UNDEFINED; |
903 |
0
|
} else if (!hasLoadedImports()) { |
904 |
0
|
return LoadingState.STATE_LOADED; |
905 |
0
|
} else if (!hasLoadedRequiredModules()) { |
906 |
0
|
return LoadingImportsState.STATE_LOADED_IMPORTED_MODULES; |
907 |
0
|
} else if (!isWellFormed()) { |
908 |
0
|
return DependencyState.STATE_LOADED_REQUIRED_MODULES; |
909 |
0
|
} else if (!isFullyFormallyProved()) { |
910 |
0
|
return WellFormedState.STATE_CHECKED; |
911 |
|
} else { |
912 |
0
|
return FormallyProvedState.STATE_CHECKED; |
913 |
|
} |
914 |
|
} |
915 |
|
|
916 |
|
|
917 |
|
@link |
918 |
|
|
919 |
|
@param |
920 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
921 |
3245
|
protected void setLoadingState(final LoadingState state) {... |
922 |
3245
|
this.loadingState = state; |
923 |
|
} |
924 |
|
|
925 |
|
|
926 |
|
@link |
927 |
|
|
928 |
|
@param |
929 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
930 |
2281
|
protected void setLoadingImportsState(final LoadingImportsState state) {... |
931 |
2281
|
this.loadingImportsState = state; |
932 |
|
} |
933 |
|
|
934 |
|
|
935 |
|
@link |
936 |
|
|
937 |
|
@param |
938 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
939 |
3647
|
protected void setDependencyState(final DependencyState state) {... |
940 |
3647
|
this.dependencyState = state; |
941 |
|
} |
942 |
|
|
943 |
|
|
944 |
|
@link |
945 |
|
|
946 |
|
@param |
947 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
948 |
4527
|
protected void setWellFormedState(final WellFormedState state) {... |
949 |
4527
|
this.wellFormedState = state; |
950 |
|
} |
951 |
|
|
952 |
|
|
953 |
|
@link |
954 |
|
|
955 |
|
@param |
956 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
957 |
1765
|
protected void setFormallyProvedState(final FormallyProvedState state) {... |
958 |
1765
|
this.formallyProvedState = state; |
959 |
|
} |
960 |
|
|
961 |
|
|
962 |
|
|
963 |
|
|
964 |
|
@return |
965 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
966 |
1195
|
public SourceFileExceptionList getErrors() {... |
967 |
1195
|
final SourceFileExceptionList result = new SourceFileExceptionList(errors); |
968 |
1195
|
result.add(pluginResults.getAllErrors()); |
969 |
1195
|
return result; |
970 |
|
} |
971 |
|
|
972 |
|
|
973 |
|
|
974 |
|
|
975 |
|
@return |
976 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
977 |
181
|
public SourceFileExceptionList getWarnings() {... |
978 |
181
|
final SourceFileExceptionList result = new SourceFileExceptionList(); |
979 |
181
|
result.add(pluginResults.getAllWarnings()); |
980 |
181
|
return result; |
981 |
|
} |
982 |
|
|
983 |
|
|
984 |
|
@link |
985 |
|
|
986 |
|
@param |
987 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
988 |
4334
|
protected void setErrors(final SourceFileExceptionList errors) {... |
989 |
4334
|
this.errors = errors; |
990 |
|
|
991 |
4334
|
if (errors == null) { |
992 |
4186
|
pluginResults = new PluginResultManager(); |
993 |
|
} |
994 |
|
} |
995 |
|
|
996 |
|
|
997 |
|
|
998 |
|
|
999 |
|
@param |
1000 |
|
@param |
1001 |
|
@param |
1002 |
|
|
|
|
| 66.7% |
Uncovered Elements: 2 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
1003 |
71
|
public void addPluginResults(final Plugin plugin, final SourceFileExceptionList errors,... |
1004 |
|
final SourceFileExceptionList warnings) { |
1005 |
71
|
if (plugin instanceof InternalPluginBo) { |
1006 |
0
|
throw new RuntimeException( |
1007 |
|
"Programming error: an internal plugin should not add exeptions here!\n" |
1008 |
|
+ plugin.getClass().getName()); |
1009 |
|
} |
1010 |
71
|
pluginResults.addResult(plugin, errors, warnings); |
1011 |
71
|
ModuleEventLog.getInstance().stateChanged(bo); |
1012 |
|
} |
1013 |
|
|
1014 |
|
|
1015 |
|
|
1016 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
1017 |
0
|
public void removeAllPluginResults() {... |
1018 |
0
|
pluginResults.removeAllResults(); |
1019 |
0
|
ModuleEventLog.getInstance().stateChanged(bo); |
1020 |
|
} |
1021 |
|
|
1022 |
|
|
1023 |
|
|
1024 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
1025 |
0
|
public void printDependencyTree() {... |
1026 |
0
|
System.out.println("DependencyTree"); |
1027 |
0
|
printDependencyTree(0); |
1028 |
0
|
System.out.println(); |
1029 |
|
} |
1030 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
1031 |
0
|
private void printDependencyTree(final int tab) {... |
1032 |
0
|
System.out.println(StringUtility.getSpaces(tab) + bo.getName()); |
1033 |
0
|
final int newTab = tab + bo.getName().length(); |
1034 |
0
|
final KernelModuleReferenceList dependent = bo.getDependentModules(); |
1035 |
0
|
for (int i = 0; i < dependent.size(); i++) { |
1036 |
0
|
DefaultKernelQedeqBo ref = (DefaultKernelQedeqBo) dependent.getKernelQedeqBo(i); |
1037 |
0
|
ref.getStateManager().printDependencyTree(newTab); |
1038 |
|
} |
1039 |
|
} |
1040 |
|
|
1041 |
|
} |