|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| |
|
16 |
| |
|
17 |
| |
|
18 |
| package org.qedeq.kernel.bo.control; |
|
19 |
| |
|
20 |
| import java.net.URL; |
|
21 |
| |
|
22 |
| import org.qedeq.kernel.base.module.Qedeq; |
|
23 |
| import org.qedeq.kernel.bo.logic.ExistenceChecker; |
|
24 |
| import org.qedeq.kernel.common.DefaultSourceFileExceptionList; |
|
25 |
| import org.qedeq.kernel.common.DependencyState; |
|
26 |
| import org.qedeq.kernel.common.LoadingState; |
|
27 |
| import org.qedeq.kernel.common.LogicalState; |
|
28 |
| import org.qedeq.kernel.common.ModuleAddress; |
|
29 |
| import org.qedeq.kernel.common.ModuleContext; |
|
30 |
| import org.qedeq.kernel.common.ModuleDataException; |
|
31 |
| import org.qedeq.kernel.common.ModuleLabels; |
|
32 |
| import org.qedeq.kernel.common.ModuleReferenceList; |
|
33 |
| import org.qedeq.kernel.common.QedeqBo; |
|
34 |
| import org.qedeq.kernel.common.SourceArea; |
|
35 |
| import org.qedeq.kernel.common.SourceFileException; |
|
36 |
| import org.qedeq.kernel.common.SourceFileExceptionList; |
|
37 |
| import org.qedeq.kernel.dto.module.QedeqVo; |
|
38 |
| import org.qedeq.kernel.utility.EqualsUtility; |
|
39 |
| |
|
40 |
| |
|
41 |
| |
|
42 |
| |
|
43 |
| |
|
44 |
| |
|
45 |
| |
|
46 |
| |
|
47 |
| public class KernelQedeqBo implements QedeqBo { |
|
48 |
| |
|
49 |
| |
|
50 |
| private final ModuleAddress address; |
|
51 |
| |
|
52 |
| |
|
53 |
| private int loadingCompleteness; |
|
54 |
| |
|
55 |
| |
|
56 |
| private LoadingState loadingState; |
|
57 |
| |
|
58 |
| |
|
59 |
| private DependencyState dependencyState; |
|
60 |
| |
|
61 |
| |
|
62 |
| private LogicalState logicalState; |
|
63 |
| |
|
64 |
| |
|
65 |
| private QedeqVo qedeq; |
|
66 |
| |
|
67 |
| |
|
68 |
| private SourceFileExceptionList exception; |
|
69 |
| |
|
70 |
| |
|
71 |
| private KernelModuleReferenceList required; |
|
72 |
| |
|
73 |
| |
|
74 |
| private KernelModuleReferenceList dependent; |
|
75 |
| |
|
76 |
| |
|
77 |
| private ExistenceChecker checker; |
|
78 |
| |
|
79 |
| |
|
80 |
| private String encoding; |
|
81 |
| |
|
82 |
| |
|
83 |
| private ModuleLabels labels; |
|
84 |
| |
|
85 |
| |
|
86 |
| private ModuleLoader loader; |
|
87 |
| |
|
88 |
| |
|
89 |
| private final StateManager stateManager; |
|
90 |
| |
|
91 |
| |
|
92 |
| |
|
93 |
| |
|
94 |
| |
|
95 |
| |
|
96 |
| |
|
97 |
204
| KernelQedeqBo(final ModuleAddress address) {
|
|
98 |
204
| this.address = address;
|
|
99 |
204
| if (address == null) {
|
|
100 |
1
| throw new NullPointerException("ModuleAddress must not be null");
|
|
101 |
| } |
|
102 |
203
| loadingState = LoadingState.STATE_UNDEFINED;
|
|
103 |
203
| loadingCompleteness = 0;
|
|
104 |
203
| dependencyState = DependencyState.STATE_UNDEFINED;
|
|
105 |
203
| logicalState = LogicalState.STATE_UNCHECKED;
|
|
106 |
203
| required = new KernelModuleReferenceList();
|
|
107 |
203
| dependent = new KernelModuleReferenceList();
|
|
108 |
203
| stateManager = new StateManager(this);
|
|
109 |
| } |
|
110 |
| |
|
111 |
| |
|
112 |
| |
|
113 |
| |
|
114 |
| |
|
115 |
| |
|
116 |
397
| public void setLoader(final ModuleLoader loader) {
|
|
117 |
397
| this.loader = loader;
|
|
118 |
| } |
|
119 |
| |
|
120 |
| |
|
121 |
| |
|
122 |
| |
|
123 |
| |
|
124 |
| |
|
125 |
9
| public ModuleLoader getLoader() {
|
|
126 |
9
| return this.loader;
|
|
127 |
| } |
|
128 |
| |
|
129 |
1517
| public boolean hasFailures() {
|
|
130 |
1517
| return loadingState.isFailure() || dependencyState.isFailure() || logicalState.isFailure();
|
|
131 |
| } |
|
132 |
| |
|
133 |
9300
| public ModuleAddress getModuleAddress() {
|
|
134 |
9300
| return address;
|
|
135 |
| } |
|
136 |
| |
|
137 |
| |
|
138 |
| |
|
139 |
| |
|
140 |
| |
|
141 |
| |
|
142 |
| |
|
143 |
| |
|
144 |
283
| public void setLoadingCompleteness(final int completeness) {
|
|
145 |
283
| this.loadingCompleteness = completeness;
|
|
146 |
| } |
|
147 |
| |
|
148 |
0
| public int getLoadingCompleteness() {
|
|
149 |
0
| return this.loadingCompleteness;
|
|
150 |
| } |
|
151 |
| |
|
152 |
| |
|
153 |
| |
|
154 |
| |
|
155 |
28
| public void delete() {
|
|
156 |
28
| stateManager.delete();
|
|
157 |
| } |
|
158 |
| |
|
159 |
| |
|
160 |
| |
|
161 |
| |
|
162 |
| |
|
163 |
| |
|
164 |
| |
|
165 |
327
| public void setLoadingProgressState(final LoadingState state) {
|
|
166 |
327
| stateManager.setLoadingProgressState(state);
|
|
167 |
| } |
|
168 |
| |
|
169 |
| |
|
170 |
| |
|
171 |
| |
|
172 |
| |
|
173 |
| |
|
174 |
| |
|
175 |
| |
|
176 |
40
| public void setLoadingFailureState(final LoadingState state,
|
|
177 |
| final SourceFileExceptionList e) { |
|
178 |
40
| stateManager.setLoadingFailureState(state, e);
|
|
179 |
| } |
|
180 |
| |
|
181 |
6489
| public LoadingState getLoadingState() {
|
|
182 |
6489
| return this.loadingState;
|
|
183 |
| } |
|
184 |
| |
|
185 |
8157
| public boolean isLoaded() {
|
|
186 |
8157
| return loadingState == LoadingState.STATE_LOADED;
|
|
187 |
| } |
|
188 |
| |
|
189 |
| |
|
190 |
| |
|
191 |
| |
|
192 |
| |
|
193 |
| |
|
194 |
| |
|
195 |
| |
|
196 |
148
| public void setLoaded(final QedeqVo qedeq, final ModuleLabels labels) {
|
|
197 |
148
| stateManager.setLoaded(qedeq, labels);
|
|
198 |
| } |
|
199 |
| |
|
200 |
0
| public String getEncoding() {
|
|
201 |
0
| return this.encoding;
|
|
202 |
| } |
|
203 |
| |
|
204 |
| |
|
205 |
| |
|
206 |
| |
|
207 |
| |
|
208 |
| |
|
209 |
155
| public void setEncoding(final String encoding) {
|
|
210 |
155
| this.encoding = encoding;
|
|
211 |
| } |
|
212 |
| |
|
213 |
1009
| public Qedeq getQedeq() {
|
|
214 |
1009
| return this.qedeq;
|
|
215 |
| } |
|
216 |
| |
|
217 |
| |
|
218 |
| |
|
219 |
| |
|
220 |
| |
|
221 |
| |
|
222 |
| |
|
223 |
| |
|
224 |
| |
|
225 |
| |
|
226 |
152
| public void setDependencyProgressState(final DependencyState state) {
|
|
227 |
152
| stateManager.setDependencyProgressState(state);
|
|
228 |
| } |
|
229 |
| |
|
230 |
| |
|
231 |
| |
|
232 |
| |
|
233 |
| |
|
234 |
| |
|
235 |
| |
|
236 |
| |
|
237 |
| |
|
238 |
| |
|
239 |
49
| public void setDependencyFailureState(final DependencyState state,
|
|
240 |
| final SourceFileExceptionList e) { |
|
241 |
49
| stateManager.setDependencyFailureState(state, e);
|
|
242 |
| } |
|
243 |
| |
|
244 |
4496
| public DependencyState getDependencyState() {
|
|
245 |
4496
| return this.dependencyState;
|
|
246 |
| } |
|
247 |
| |
|
248 |
| |
|
249 |
| |
|
250 |
| |
|
251 |
| |
|
252 |
| |
|
253 |
| |
|
254 |
115
| public void setLoadedRequiredModules(final KernelModuleReferenceList list) {
|
|
255 |
115
| stateManager.setLoadedRequiredModules(list);
|
|
256 |
| } |
|
257 |
| |
|
258 |
1317
| public ModuleReferenceList getRequiredModules() {
|
|
259 |
1317
| return getKernelRequiredModules();
|
|
260 |
| } |
|
261 |
| |
|
262 |
| |
|
263 |
| |
|
264 |
| |
|
265 |
| |
|
266 |
| |
|
267 |
2620
| public KernelModuleReferenceList getKernelRequiredModules() {
|
|
268 |
2620
| return required;
|
|
269 |
| } |
|
270 |
| |
|
271 |
3731
| public boolean hasLoadedRequiredModules() {
|
|
272 |
3731
| return isLoaded() && dependencyState == DependencyState.STATE_LOADED_REQUIRED_MODULES;
|
|
273 |
| } |
|
274 |
| |
|
275 |
| |
|
276 |
| |
|
277 |
| |
|
278 |
| |
|
279 |
| |
|
280 |
1163
| public KernelModuleReferenceList getDependentModules() {
|
|
281 |
1163
| return dependent;
|
|
282 |
| } |
|
283 |
| |
|
284 |
| |
|
285 |
| |
|
286 |
| |
|
287 |
| |
|
288 |
| |
|
289 |
70
| public void setChecked(final ExistenceChecker checker) {
|
|
290 |
70
| stateManager.setChecked(checker);
|
|
291 |
| } |
|
292 |
| |
|
293 |
| |
|
294 |
| |
|
295 |
| |
|
296 |
| |
|
297 |
| |
|
298 |
| |
|
299 |
2011
| public ExistenceChecker getExistenceChecker() {
|
|
300 |
2011
| return checker;
|
|
301 |
| } |
|
302 |
| |
|
303 |
1096
| public boolean isChecked() {
|
|
304 |
1096
| return isLoaded() && hasLoadedRequiredModules()
|
|
305 |
| && logicalState == LogicalState.STATE_CHECKED; |
|
306 |
| } |
|
307 |
| |
|
308 |
| |
|
309 |
| |
|
310 |
| |
|
311 |
| |
|
312 |
| |
|
313 |
180
| public void setLogicalProgressState(final LogicalState state) {
|
|
314 |
180
| stateManager.setLogicalProgressState(state);
|
|
315 |
| } |
|
316 |
| |
|
317 |
| |
|
318 |
| |
|
319 |
| |
|
320 |
| |
|
321 |
| |
|
322 |
| |
|
323 |
| |
|
324 |
21
| public void setLogicalFailureState(final LogicalState state,
|
|
325 |
| final SourceFileExceptionList e) { |
|
326 |
21
| stateManager.setLogicalFailureState(state, e);
|
|
327 |
| } |
|
328 |
| |
|
329 |
3830
| public LogicalState getLogicalState() {
|
|
330 |
3830
| return this.logicalState;
|
|
331 |
| } |
|
332 |
| |
|
333 |
371
| public SourceFileExceptionList getException() {
|
|
334 |
371
| return this.exception;
|
|
335 |
| } |
|
336 |
| |
|
337 |
| |
|
338 |
| |
|
339 |
| |
|
340 |
| |
|
341 |
| |
|
342 |
| |
|
343 |
| |
|
344 |
0
| public SourceFileExceptionList getWarnings() {
|
|
345 |
0
| return null;
|
|
346 |
| } |
|
347 |
| |
|
348 |
2693
| public String getStateDescription() {
|
|
349 |
2693
| if (loadingState == LoadingState.STATE_LOADING_FROM_WEB) {
|
|
350 |
264
| return loadingState.getText() + " (" + loadingCompleteness + "%)";
|
|
351 |
2429
| } else if (!isLoaded()) {
|
|
352 |
1515
| return loadingState.getText();
|
|
353 |
914
| } else if (!hasLoadedRequiredModules()) {
|
|
354 |
419
| if (dependencyState == DependencyState.STATE_UNDEFINED) {
|
|
355 |
191
| return loadingState.getText();
|
|
356 |
| } |
|
357 |
228
| return dependencyState.getText();
|
|
358 |
495
| } else if (!isChecked()) {
|
|
359 |
321
| if (logicalState == LogicalState.STATE_UNCHECKED) {
|
|
360 |
114
| return dependencyState.getText();
|
|
361 |
| } |
|
362 |
207
| return logicalState.getText();
|
|
363 |
| } |
|
364 |
174
| return logicalState.getText();
|
|
365 |
| } |
|
366 |
| |
|
367 |
4269
| public String getName() {
|
|
368 |
4269
| if (address == null) {
|
|
369 |
0
| return "null";
|
|
370 |
| } |
|
371 |
4269
| return address.getName();
|
|
372 |
| } |
|
373 |
| |
|
374 |
439
| public String getRuleVersion() {
|
|
375 |
439
| if (address == null || qedeq == null
|
|
376 |
| || qedeq.getHeader() == null |
|
377 |
| || qedeq.getHeader().getSpecification() == null |
|
378 |
| || qedeq.getHeader().getSpecification().getRuleVersion() == null) { |
|
379 |
254
| return "";
|
|
380 |
| } |
|
381 |
185
| return qedeq.getHeader().getSpecification().getRuleVersion();
|
|
382 |
| } |
|
383 |
| |
|
384 |
4888
| public URL getUrl() {
|
|
385 |
4888
| if (this.address == null) {
|
|
386 |
0
| return null;
|
|
387 |
| } |
|
388 |
4888
| return this.address.getURL();
|
|
389 |
| } |
|
390 |
| |
|
391 |
| |
|
392 |
| |
|
393 |
| |
|
394 |
| |
|
395 |
| |
|
396 |
530
| public void setLabels(final ModuleLabels labels) {
|
|
397 |
530
| this.labels = labels;
|
|
398 |
| } |
|
399 |
| |
|
400 |
| |
|
401 |
| |
|
402 |
| |
|
403 |
| |
|
404 |
| |
|
405 |
10
| public ModuleLabels getLabels() {
|
|
406 |
10
| return labels;
|
|
407 |
| } |
|
408 |
| |
|
409 |
| |
|
410 |
| |
|
411 |
| |
|
412 |
| |
|
413 |
| |
|
414 |
| |
|
415 |
0
| public SourceFileExceptionList createSourceFileExceptionList(
|
|
416 |
| final ModuleDataException exception) { |
|
417 |
0
| final SourceFileException e = new SourceFileException(exception, createSourceArea(qedeq,
|
|
418 |
| exception.getContext()), loader.createSourceArea(qedeq, |
|
419 |
| exception.getReferenceContext())); |
|
420 |
0
| final DefaultSourceFileExceptionList list = new DefaultSourceFileExceptionList(e);
|
|
421 |
0
| return list;
|
|
422 |
| } |
|
423 |
| |
|
424 |
| |
|
425 |
| |
|
426 |
| |
|
427 |
| |
|
428 |
| |
|
429 |
| |
|
430 |
| |
|
431 |
| |
|
432 |
0
| public SourceFileExceptionList createSourceFileExceptionList(
|
|
433 |
| final ModuleDataException exception, final Qedeq qedeq) { |
|
434 |
0
| final SourceFileException e = new SourceFileException(exception, createSourceArea(qedeq,
|
|
435 |
| exception.getContext()), loader.createSourceArea(qedeq, |
|
436 |
| exception.getReferenceContext())); |
|
437 |
0
| final DefaultSourceFileExceptionList list = new DefaultSourceFileExceptionList(e);
|
|
438 |
0
| return list;
|
|
439 |
| } |
|
440 |
| |
|
441 |
| |
|
442 |
| |
|
443 |
| |
|
444 |
| |
|
445 |
| |
|
446 |
| |
|
447 |
79
| public SourceFileException createSourceFileException(final ModuleDataException
|
|
448 |
| exception) { |
|
449 |
79
| final SourceFileException e = new SourceFileException(exception, createSourceArea(qedeq,
|
|
450 |
| exception.getContext()), loader.createSourceArea(qedeq, |
|
451 |
| exception.getReferenceContext())); |
|
452 |
79
| return e;
|
|
453 |
| } |
|
454 |
| |
|
455 |
| |
|
456 |
| |
|
457 |
| |
|
458 |
| |
|
459 |
| |
|
460 |
| |
|
461 |
| |
|
462 |
79
| public SourceArea createSourceArea(final Qedeq qedeq, final ModuleContext context) {
|
|
463 |
79
| return loader.createSourceArea(qedeq, context);
|
|
464 |
| } |
|
465 |
| |
|
466 |
| |
|
467 |
| |
|
468 |
| |
|
469 |
| |
|
470 |
| |
|
471 |
676
| protected void setQedeqVo(final QedeqVo qedeq) {
|
|
472 |
676
| this.qedeq = qedeq;
|
|
473 |
| } |
|
474 |
| |
|
475 |
| |
|
476 |
| |
|
477 |
| |
|
478 |
| |
|
479 |
| |
|
480 |
552
| protected void setLoadingState(final LoadingState state) {
|
|
481 |
552
| this.loadingState = state;
|
|
482 |
| } |
|
483 |
| |
|
484 |
| |
|
485 |
| |
|
486 |
| |
|
487 |
| |
|
488 |
| |
|
489 |
851
| protected void setDependencyState(final DependencyState state) {
|
|
490 |
851
| this.dependencyState = state;
|
|
491 |
| } |
|
492 |
| |
|
493 |
| |
|
494 |
| |
|
495 |
| |
|
496 |
| |
|
497 |
| |
|
498 |
964
| protected void setLogicalState(final LogicalState state) {
|
|
499 |
964
| this.logicalState = state;
|
|
500 |
| } |
|
501 |
| |
|
502 |
| |
|
503 |
| |
|
504 |
| |
|
505 |
| |
|
506 |
| |
|
507 |
937
| protected void setException(final SourceFileExceptionList exception) {
|
|
508 |
937
| this.exception = exception;
|
|
509 |
| } |
|
510 |
| |
|
511 |
| |
|
512 |
| |
|
513 |
| |
|
514 |
| |
|
515 |
| |
|
516 |
11
| protected StateManager getStateManager() {
|
|
517 |
11
| return this.stateManager;
|
|
518 |
| } |
|
519 |
| |
|
520 |
| |
|
521 |
| |
|
522 |
| |
|
523 |
| |
|
524 |
| |
|
525 |
70
| protected void setExistenceChecker(final ExistenceChecker checker) {
|
|
526 |
70
| this.checker = checker;
|
|
527 |
| } |
|
528 |
| |
|
529 |
614
| public int hashCode() {
|
|
530 |
614
| return (getModuleAddress() == null ? 0 : getModuleAddress().hashCode());
|
|
531 |
| } |
|
532 |
| |
|
533 |
1887
| public boolean equals(final Object obj) {
|
|
534 |
1887
| if (obj instanceof KernelQedeqBo) {
|
|
535 |
1887
| return EqualsUtility.equals(((KernelQedeqBo) obj).getModuleAddress(),
|
|
536 |
| this.getModuleAddress()); |
|
537 |
| } |
|
538 |
0
| return false;
|
|
539 |
| } |
|
540 |
| |
|
541 |
1023
| public String toString() {
|
|
542 |
1023
| return address.getURL().toString();
|
|
543 |
| } |
|
544 |
| |
|
545 |
| } |