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 org.qedeq.kernel.base.list.Element; |
21 |
| import org.qedeq.kernel.base.module.Author; |
22 |
| import org.qedeq.kernel.base.module.AuthorList; |
23 |
| import org.qedeq.kernel.base.module.Axiom; |
24 |
| import org.qedeq.kernel.base.module.Chapter; |
25 |
| import org.qedeq.kernel.base.module.ChapterList; |
26 |
| import org.qedeq.kernel.base.module.Formula; |
27 |
| import org.qedeq.kernel.base.module.FunctionDefinition; |
28 |
| import org.qedeq.kernel.base.module.Header; |
29 |
| import org.qedeq.kernel.base.module.Import; |
30 |
| import org.qedeq.kernel.base.module.ImportList; |
31 |
| import org.qedeq.kernel.base.module.Latex; |
32 |
| import org.qedeq.kernel.base.module.LatexList; |
33 |
| import org.qedeq.kernel.base.module.LinkList; |
34 |
| import org.qedeq.kernel.base.module.LiteratureItem; |
35 |
| import org.qedeq.kernel.base.module.LiteratureItemList; |
36 |
| import org.qedeq.kernel.base.module.Location; |
37 |
| import org.qedeq.kernel.base.module.LocationList; |
38 |
| import org.qedeq.kernel.base.module.Node; |
39 |
| import org.qedeq.kernel.base.module.PredicateDefinition; |
40 |
| import org.qedeq.kernel.base.module.Proof; |
41 |
| import org.qedeq.kernel.base.module.ProofList; |
42 |
| import org.qedeq.kernel.base.module.Proposition; |
43 |
| import org.qedeq.kernel.base.module.Qedeq; |
44 |
| import org.qedeq.kernel.base.module.Rule; |
45 |
| import org.qedeq.kernel.base.module.Section; |
46 |
| import org.qedeq.kernel.base.module.SectionList; |
47 |
| import org.qedeq.kernel.base.module.Specification; |
48 |
| import org.qedeq.kernel.base.module.Subsection; |
49 |
| import org.qedeq.kernel.base.module.SubsectionList; |
50 |
| import org.qedeq.kernel.base.module.Term; |
51 |
| import org.qedeq.kernel.base.module.UsedByList; |
52 |
| import org.qedeq.kernel.base.module.VariableList; |
53 |
| import org.qedeq.kernel.bo.module.DuplicateLanguageEntryException; |
54 |
| import org.qedeq.kernel.bo.module.IllegalModuleDataException; |
55 |
| import org.qedeq.kernel.bo.module.ModuleDataException; |
56 |
| import org.qedeq.kernel.bo.module.NullPointerListEntryException; |
57 |
| import org.qedeq.kernel.bo.module.QedeqBo; |
58 |
| import org.qedeq.kernel.context.ModuleContext; |
59 |
| import org.qedeq.kernel.dto.module.AuthorListVo; |
60 |
| import org.qedeq.kernel.dto.module.AuthorVo; |
61 |
| import org.qedeq.kernel.dto.module.AxiomVo; |
62 |
| import org.qedeq.kernel.dto.module.ChapterListVo; |
63 |
| import org.qedeq.kernel.dto.module.ChapterVo; |
64 |
| import org.qedeq.kernel.dto.module.FormulaVo; |
65 |
| import org.qedeq.kernel.dto.module.FunctionDefinitionVo; |
66 |
| import org.qedeq.kernel.dto.module.HeaderVo; |
67 |
| import org.qedeq.kernel.dto.module.ImportListVo; |
68 |
| import org.qedeq.kernel.dto.module.ImportVo; |
69 |
| import org.qedeq.kernel.dto.module.LatexListVo; |
70 |
| import org.qedeq.kernel.dto.module.LatexVo; |
71 |
| import org.qedeq.kernel.dto.module.LinkListVo; |
72 |
| import org.qedeq.kernel.dto.module.LiteratureItemListVo; |
73 |
| import org.qedeq.kernel.dto.module.LiteratureItemVo; |
74 |
| import org.qedeq.kernel.dto.module.LocationListVo; |
75 |
| import org.qedeq.kernel.dto.module.LocationVo; |
76 |
| import org.qedeq.kernel.dto.module.NodeVo; |
77 |
| import org.qedeq.kernel.dto.module.PredicateDefinitionVo; |
78 |
| import org.qedeq.kernel.dto.module.ProofListVo; |
79 |
| import org.qedeq.kernel.dto.module.ProofVo; |
80 |
| import org.qedeq.kernel.dto.module.PropositionVo; |
81 |
| import org.qedeq.kernel.dto.module.RuleVo; |
82 |
| import org.qedeq.kernel.dto.module.SectionListVo; |
83 |
| import org.qedeq.kernel.dto.module.SectionVo; |
84 |
| import org.qedeq.kernel.dto.module.SpecificationVo; |
85 |
| import org.qedeq.kernel.dto.module.SubsectionListVo; |
86 |
| import org.qedeq.kernel.dto.module.SubsectionVo; |
87 |
| import org.qedeq.kernel.dto.module.TermVo; |
88 |
| import org.qedeq.kernel.dto.module.UsedByListVo; |
89 |
| import org.qedeq.kernel.dto.module.VariableListVo; |
90 |
| |
91 |
| |
92 |
| |
93 |
| |
94 |
| |
95 |
| |
96 |
| |
97 |
| |
98 |
| |
99 |
| |
100 |
| public class QedeqBoFactory { |
101 |
| |
102 |
| |
103 |
| private QedeqBo qedeq; |
104 |
| |
105 |
| |
106 |
| private Qedeq original; |
107 |
| |
108 |
| |
109 |
| private ModuleContext currentContext; |
110 |
| |
111 |
| |
112 |
| |
113 |
| |
114 |
| |
115 |
| |
116 |
16
| protected QedeqBoFactory(final String globalContext) {
|
117 |
16
| currentContext = new ModuleContext(globalContext);
|
118 |
| } |
119 |
| |
120 |
| |
121 |
| |
122 |
| |
123 |
| |
124 |
| |
125 |
| |
126 |
| |
127 |
| |
128 |
| |
129 |
| |
130 |
| |
131 |
| |
132 |
| |
133 |
| |
134 |
11
| public static QedeqBo createQedeq(final String globalContext, final Qedeq original)
|
135 |
| throws ModuleDataException { |
136 |
11
| final QedeqBoFactory creator = new QedeqBoFactory(globalContext);
|
137 |
11
| QedeqBo bo = creator.create(original);
|
138 |
10
| QedeqBoFormalLogicChecker.check(globalContext, bo);
|
139 |
10
| return bo;
|
140 |
| } |
141 |
| |
142 |
| |
143 |
| |
144 |
| |
145 |
| |
146 |
| |
147 |
| |
148 |
| |
149 |
| |
150 |
| |
151 |
| |
152 |
| |
153 |
| |
154 |
| |
155 |
16
| protected final QedeqBo create(final Qedeq original) throws IllegalModuleDataException {
|
156 |
16
| this.original = original;
|
157 |
16
| getCurrentContext().setLocationWithinModule("");
|
158 |
16
| if (original == null) {
|
159 |
0
| qedeq = null;
|
160 |
0
| return qedeq;
|
161 |
| } |
162 |
16
| qedeq = new QedeqBo();
|
163 |
16
| final String context = getCurrentContext().getLocationWithinModule();
|
164 |
16
| if (original.getHeader() != null) {
|
165 |
16
| getCurrentContext().setLocationWithinModule(context + "getHeader()");
|
166 |
16
| qedeq.setHeader(create(original.getHeader()));
|
167 |
| } |
168 |
16
| if (original.getChapterList() != null) {
|
169 |
16
| getCurrentContext().setLocationWithinModule(context + "getChapterList()");
|
170 |
16
| qedeq.setChapterList(create(original.getChapterList()));
|
171 |
| } |
172 |
14
| if (original.getLiteratureItemList() != null) {
|
173 |
6
| getCurrentContext().setLocationWithinModule(context + "getLiteratureItemList()");
|
174 |
6
| qedeq.setLiteratureItemList(create(original.getLiteratureItemList()));
|
175 |
| } |
176 |
14
| return qedeq;
|
177 |
| } |
178 |
| |
179 |
| |
180 |
| |
181 |
| |
182 |
| |
183 |
| |
184 |
| |
185 |
| |
186 |
| |
187 |
| |
188 |
| |
189 |
| |
190 |
| |
191 |
| |
192 |
16
| private final HeaderVo create(final Header header)
|
193 |
| throws IllegalModuleDataException { |
194 |
16
| if (header == null) {
|
195 |
0
| return null;
|
196 |
| } |
197 |
16
| final HeaderVo h = new HeaderVo();
|
198 |
16
| final String context = getCurrentContext().getLocationWithinModule();
|
199 |
16
| if (header.getTitle() != null) {
|
200 |
16
| setLocationWithinModule(context + ".getTitle()");
|
201 |
16
| h.setTitle(create(header.getTitle()));
|
202 |
| } |
203 |
16
| if (header.getAuthorList() != null) {
|
204 |
16
| setLocationWithinModule(context + ".getAuthorList()");
|
205 |
16
| h.setAuthorList(create(header.getAuthorList()));
|
206 |
| } |
207 |
16
| if (header.getSummary() != null) {
|
208 |
16
| setLocationWithinModule(context + ".getSummary()");
|
209 |
16
| h.setSummary(create(header.getSummary()));
|
210 |
| } |
211 |
16
| if (header.getEmail() != null) {
|
212 |
16
| setLocationWithinModule(context + ".getEmail()");
|
213 |
16
| h.setEmail(header.getEmail());
|
214 |
| } |
215 |
16
| if (header.getSpecification() != null) {
|
216 |
16
| setLocationWithinModule(context + ".getSpecification()");
|
217 |
16
| h.setSpecification(create(header.getSpecification()));
|
218 |
| } |
219 |
16
| if (header.getImportList() != null) {
|
220 |
8
| setLocationWithinModule(context + ".getImportList()");
|
221 |
8
| h.setImportList(create(header.getImportList()));
|
222 |
| } |
223 |
16
| if (header.getUsedByList() != null) {
|
224 |
5
| setLocationWithinModule(context + ".getUsedByList()");
|
225 |
5
| h.setUsedByList(create(header.getUsedByList()));
|
226 |
| } |
227 |
16
| setLocationWithinModule(context);
|
228 |
16
| return h;
|
229 |
| } |
230 |
| |
231 |
| |
232 |
| |
233 |
| |
234 |
| |
235 |
| |
236 |
| |
237 |
| |
238 |
| |
239 |
| |
240 |
| |
241 |
| |
242 |
| |
243 |
5
| private final UsedByListVo create(final UsedByList usedByList) {
|
244 |
5
| if (usedByList == null) {
|
245 |
0
| return null;
|
246 |
| } |
247 |
5
| final String context = getCurrentContext().getLocationWithinModule();
|
248 |
5
| final UsedByListVo list = new UsedByListVo();
|
249 |
5
| for (int i = 0; i < usedByList.size(); i++) {
|
250 |
5
| setLocationWithinModule(context + ".get(" + i + ")");
|
251 |
5
| list.add(create(usedByList.get(i)));
|
252 |
| } |
253 |
5
| setLocationWithinModule(context);
|
254 |
5
| return list;
|
255 |
| } |
256 |
| |
257 |
8
| private final ImportListVo create(final ImportList importList) {
|
258 |
8
| if (importList == null) {
|
259 |
0
| return null;
|
260 |
| } |
261 |
8
| final String context = getCurrentContext().getLocationWithinModule();
|
262 |
8
| final ImportListVo list = new ImportListVo();
|
263 |
8
| for (int i = 0; i < importList.size(); i++) {
|
264 |
13
| setLocationWithinModule(context + ".get(" + i + ")");
|
265 |
13
| list.add(create(importList.get(i)));
|
266 |
| } |
267 |
8
| setLocationWithinModule(context);
|
268 |
8
| return list;
|
269 |
| } |
270 |
| |
271 |
13
| private final ImportVo create(final Import imp) {
|
272 |
13
| if (imp == null) {
|
273 |
0
| return null;
|
274 |
| } |
275 |
13
| final ImportVo i = new ImportVo();
|
276 |
13
| final String context = getCurrentContext().getLocationWithinModule();
|
277 |
13
| if (imp.getLabel() != null) {
|
278 |
13
| setLocationWithinModule(context + ".getLabel()");
|
279 |
13
| i.setLabel(imp.getLabel());
|
280 |
| } |
281 |
13
| if (imp.getSpecification() != null) {
|
282 |
13
| setLocationWithinModule(context + ".getSpecification()");
|
283 |
13
| i.setSpecification(create(imp.getSpecification()));
|
284 |
| } |
285 |
13
| setLocationWithinModule(context);
|
286 |
13
| return i;
|
287 |
| } |
288 |
| |
289 |
34
| private final SpecificationVo create(final Specification specification) {
|
290 |
34
| if (specification == null) {
|
291 |
0
| return null;
|
292 |
| } |
293 |
34
| final SpecificationVo s = new SpecificationVo();
|
294 |
34
| final String context = getCurrentContext().getLocationWithinModule();
|
295 |
34
| if (specification.getName() != null) {
|
296 |
34
| setLocationWithinModule(context + ".getName()");
|
297 |
34
| s.setName(specification.getName());
|
298 |
| } |
299 |
34
| if (specification.getRuleVersion() != null) {
|
300 |
34
| setLocationWithinModule(context + ".getRuleVersion()");
|
301 |
34
| s.setRuleVersion(specification.getRuleVersion());
|
302 |
| } |
303 |
34
| if (specification.getLocationList() != null) {
|
304 |
34
| setLocationWithinModule(context + ".getLocationList()");
|
305 |
34
| s.setLocationList(create(specification.getLocationList()));
|
306 |
| } |
307 |
34
| setLocationWithinModule(context);
|
308 |
34
| return s;
|
309 |
| } |
310 |
| |
311 |
34
| private final LocationListVo create(final LocationList locationList) {
|
312 |
34
| if (locationList == null) {
|
313 |
0
| return null;
|
314 |
| } |
315 |
34
| final LocationListVo list = new LocationListVo();
|
316 |
34
| final String context = getCurrentContext().getLocationWithinModule();
|
317 |
34
| for (int i = 0; i < locationList.size(); i++) {
|
318 |
34
| setLocationWithinModule(context + ".get(" + i + ")");
|
319 |
34
| list.add(create(locationList.get(i)));
|
320 |
| } |
321 |
34
| setLocationWithinModule(context);
|
322 |
34
| return list;
|
323 |
| } |
324 |
| |
325 |
34
| private final LocationVo create(final Location location) {
|
326 |
34
| if (location == null) {
|
327 |
0
| return null;
|
328 |
| } |
329 |
34
| final LocationVo loc = new LocationVo();
|
330 |
34
| final String context = getCurrentContext().getLocationWithinModule();
|
331 |
34
| if (location.getLocation() != null) {
|
332 |
34
| setLocationWithinModule(context + ".getLocation()");
|
333 |
34
| loc.setLocation(location.getLocation());
|
334 |
| } |
335 |
34
| setLocationWithinModule(context);
|
336 |
34
| return loc;
|
337 |
| } |
338 |
| |
339 |
16
| private final AuthorListVo create(final AuthorList authorList) {
|
340 |
16
| if (authorList == null) {
|
341 |
0
| return null;
|
342 |
| } |
343 |
16
| final AuthorListVo list = new AuthorListVo();
|
344 |
16
| final String context = getCurrentContext().getLocationWithinModule();
|
345 |
16
| for (int i = 0; i < authorList.size(); i++) {
|
346 |
16
| setLocationWithinModule(context + ".get(" + i + ")");
|
347 |
16
| list.add(create(authorList.get(i)));
|
348 |
| } |
349 |
16
| setLocationWithinModule(context);
|
350 |
16
| return list;
|
351 |
| } |
352 |
| |
353 |
16
| private final AuthorVo create(final Author author) {
|
354 |
16
| if (author == null) {
|
355 |
0
| return null;
|
356 |
| } |
357 |
16
| final AuthorVo a = new AuthorVo();
|
358 |
16
| final String context = getCurrentContext().getLocationWithinModule();
|
359 |
16
| if (author.getName() != null) {
|
360 |
16
| setLocationWithinModule(context + ".getName()");
|
361 |
16
| a.setName(create(author.getName()));
|
362 |
| } |
363 |
16
| if (author.getEmail() != null) {
|
364 |
16
| setLocationWithinModule(context + ".getEmail()");
|
365 |
16
| a.setEmail(author.getEmail());
|
366 |
| } |
367 |
16
| setLocationWithinModule(context);
|
368 |
16
| return a;
|
369 |
| } |
370 |
| |
371 |
16
| private final ChapterListVo create(final ChapterList chapterList)
|
372 |
| throws IllegalModuleDataException { |
373 |
16
| if (chapterList == null) {
|
374 |
0
| return null;
|
375 |
| } |
376 |
16
| final ChapterListVo list = new ChapterListVo();
|
377 |
16
| final String context = getCurrentContext().getLocationWithinModule();
|
378 |
16
| for (int i = 0; i < chapterList.size(); i++) {
|
379 |
75
| setLocationWithinModule(context + ".get(" + i + ")");
|
380 |
75
| list.add(create(chapterList.get(i)));
|
381 |
| } |
382 |
14
| setLocationWithinModule(context);
|
383 |
14
| return list;
|
384 |
| } |
385 |
| |
386 |
75
| private final ChapterVo create(final Chapter chapter)
|
387 |
| throws IllegalModuleDataException { |
388 |
75
| if (chapter == null) {
|
389 |
0
| return null;
|
390 |
| } |
391 |
75
| final ChapterVo c = new ChapterVo();
|
392 |
75
| final String context = getCurrentContext().getLocationWithinModule();
|
393 |
75
| if (chapter.getTitle() != null) {
|
394 |
75
| setLocationWithinModule(context + ".getTitle()");
|
395 |
75
| c.setTitle(create(chapter.getTitle()));
|
396 |
| } |
397 |
75
| if (chapter.getNoNumber() != null) {
|
398 |
25
| setLocationWithinModule(context + ".getNoNumber()");
|
399 |
25
| c.setNoNumber(chapter.getNoNumber());
|
400 |
| } |
401 |
75
| if (chapter.getIntroduction() != null) {
|
402 |
75
| setLocationWithinModule(context + ".getIntroduction()");
|
403 |
75
| c.setIntroduction(create(chapter.getIntroduction()));
|
404 |
| } |
405 |
75
| if (chapter.getSectionList() != null) {
|
406 |
43
| setLocationWithinModule(context + ".getSectionList()");
|
407 |
43
| c.setSectionList(create(chapter.getSectionList()));
|
408 |
| } |
409 |
73
| setLocationWithinModule(context);
|
410 |
73
| return c;
|
411 |
| } |
412 |
| |
413 |
6
| private LiteratureItemListVo create(final LiteratureItemList literatureItemList)
|
414 |
| throws IllegalModuleDataException { |
415 |
6
| if (literatureItemList == null) {
|
416 |
0
| return null;
|
417 |
| } |
418 |
6
| final LiteratureItemListVo list = new LiteratureItemListVo();
|
419 |
6
| final String context = getCurrentContext().getLocationWithinModule();
|
420 |
6
| for (int i = 0; i < literatureItemList.size(); i++) {
|
421 |
27
| setLocationWithinModule(context + ".get(" + i + ")");
|
422 |
27
| list.add(create(literatureItemList.get(i)));
|
423 |
| } |
424 |
6
| setLocationWithinModule(context);
|
425 |
6
| return list;
|
426 |
| } |
427 |
| |
428 |
27
| private LiteratureItemVo create(final LiteratureItem item)
|
429 |
| throws IllegalModuleDataException { |
430 |
27
| if (item == null) {
|
431 |
0
| return null;
|
432 |
| } |
433 |
27
| final LiteratureItemVo it = new LiteratureItemVo();
|
434 |
27
| final String context = getCurrentContext().getLocationWithinModule();
|
435 |
27
| if (item.getLabel() != null) {
|
436 |
27
| setLocationWithinModule(context + ".getLabel()");
|
437 |
27
| it.setLabel(item.getLabel());
|
438 |
| } |
439 |
27
| if (item.getItem() != null) {
|
440 |
27
| setLocationWithinModule(context + ".getItem()");
|
441 |
27
| it.setItem(create(item.getItem()));
|
442 |
| } |
443 |
27
| setLocationWithinModule(context);
|
444 |
27
| return it;
|
445 |
| |
446 |
| } |
447 |
| |
448 |
43
| private final SectionListVo create(final SectionList sectionList)
|
449 |
| throws IllegalModuleDataException { |
450 |
43
| if (sectionList == null) {
|
451 |
0
| return null;
|
452 |
| } |
453 |
43
| final SectionListVo list = new SectionListVo();
|
454 |
43
| final String context = getCurrentContext().getLocationWithinModule();
|
455 |
43
| for (int i = 0; i < sectionList.size(); i++) {
|
456 |
125
| setLocationWithinModule(context + ".get(" + i + ")");
|
457 |
125
| list.add(create(sectionList.get(i)));
|
458 |
| } |
459 |
41
| setLocationWithinModule(context);
|
460 |
41
| return list;
|
461 |
| } |
462 |
| |
463 |
125
| private final SectionVo create(final Section section)
|
464 |
| throws IllegalModuleDataException { |
465 |
125
| if (section == null) {
|
466 |
0
| return null;
|
467 |
| } |
468 |
125
| final SectionVo s = new SectionVo();
|
469 |
125
| final String context = getCurrentContext().getLocationWithinModule();
|
470 |
125
| if (section.getTitle() != null) {
|
471 |
125
| setLocationWithinModule(context + ".getTitle()");
|
472 |
125
| s.setTitle(create(section.getTitle()));
|
473 |
| } |
474 |
125
| if (section.getNoNumber() != null) {
|
475 |
0
| setLocationWithinModule(context + ".getNoNumber()");
|
476 |
0
| s.setNoNumber(section.getNoNumber());
|
477 |
| } |
478 |
125
| if (section.getIntroduction() != null) {
|
479 |
125
| setLocationWithinModule(context + ".getIntroduction()");
|
480 |
125
| s.setIntroduction(create(section.getIntroduction()));
|
481 |
| } |
482 |
125
| if (section.getSubsectionList() != null) {
|
483 |
60
| setLocationWithinModule(context + ".getSubsectionList()");
|
484 |
60
| s.setSubsectionList(create(section.getSubsectionList()));
|
485 |
| } |
486 |
123
| setLocationWithinModule(context);
|
487 |
123
| return s;
|
488 |
| } |
489 |
| |
490 |
60
| private final SubsectionListVo create(final SubsectionList subsectionList)
|
491 |
| throws IllegalModuleDataException { |
492 |
60
| if (subsectionList == null) {
|
493 |
0
| return null;
|
494 |
| } |
495 |
60
| final SubsectionListVo list = new SubsectionListVo();
|
496 |
60
| final String context = getCurrentContext().getLocationWithinModule();
|
497 |
60
| for (int i = 0; i < subsectionList.size(); i++) {
|
498 |
367
| setLocationWithinModule(context + ".get(" + i + ")");
|
499 |
| |
500 |
367
| if (subsectionList.get(i) instanceof Subsection) {
|
501 |
61
| list.add(create((Subsection) subsectionList.get(i)));
|
502 |
306
| } else if (subsectionList.get(i) instanceof Node) {
|
503 |
306
| list.add(create((Node) subsectionList.get(i)));
|
504 |
| } else { |
505 |
0
| throw new IllegalArgumentException("unexpected subsection type: "
|
506 |
| + subsectionList.get(i).getClass()); |
507 |
| } |
508 |
| } |
509 |
58
| setLocationWithinModule(context);
|
510 |
58
| return list;
|
511 |
| } |
512 |
| |
513 |
61
| private final SubsectionVo create(final Subsection subsection)
|
514 |
| throws IllegalModuleDataException { |
515 |
61
| if (subsection == null) {
|
516 |
0
| return null;
|
517 |
| } |
518 |
61
| final SubsectionVo s = new SubsectionVo();
|
519 |
61
| final String context = getCurrentContext().getLocationWithinModule();
|
520 |
61
| if (subsection.getTitle() != null) {
|
521 |
52
| setLocationWithinModule(context + ".getTitle()");
|
522 |
52
| s.setTitle(create(subsection.getTitle()));
|
523 |
| } |
524 |
61
| if (subsection.getLevel() != null) {
|
525 |
0
| setLocationWithinModule(context + ".getLevel()");
|
526 |
0
| s.setLevel(subsection.getLevel());
|
527 |
| } |
528 |
61
| if (subsection.getLatex() != null) {
|
529 |
61
| setLocationWithinModule(context + ".getLatex()");
|
530 |
61
| s.setLatex(create(subsection.getLatex()));
|
531 |
| } |
532 |
61
| setLocationWithinModule(context);
|
533 |
61
| return s;
|
534 |
| } |
535 |
| |
536 |
306
| private final NodeVo create(final Node node)
|
537 |
| throws IllegalModuleDataException { |
538 |
306
| if (node == null) {
|
539 |
0
| return null;
|
540 |
| } |
541 |
306
| final NodeVo n = new NodeVo();
|
542 |
306
| final String context = getCurrentContext().getLocationWithinModule();
|
543 |
306
| if (node.getName() != null) {
|
544 |
144
| setLocationWithinModule(context + ".getName()");
|
545 |
144
| n.setName(create(node.getName()));
|
546 |
| } |
547 |
306
| if (node.getId() != null) {
|
548 |
306
| setLocationWithinModule(context + ".getId()");
|
549 |
306
| n.setId(node.getId());
|
550 |
| } |
551 |
306
| if (node.getLevel() != null) {
|
552 |
216
| setLocationWithinModule(context + ".getLevel()");
|
553 |
216
| n.setLevel(node.getLevel());
|
554 |
| } |
555 |
306
| if (node.getTitle() != null) {
|
556 |
144
| setLocationWithinModule(context + ".getTitle()");
|
557 |
144
| n.setTitle(create(node.getTitle()));
|
558 |
| } |
559 |
306
| if (node.getPrecedingText() != null) {
|
560 |
306
| setLocationWithinModule(context + ".getPrecedingText()");
|
561 |
306
| n.setPrecedingText(create(node.getPrecedingText()));
|
562 |
| } |
563 |
306
| if (node.getNodeType() != null) {
|
564 |
306
| setLocationWithinModule(context + ".getNodeType()");
|
565 |
306
| if (node.getNodeType() instanceof Axiom) {
|
566 |
50
| setLocationWithinModule(context + ".getNodeType().getAxiom()");
|
567 |
50
| n.setNodeType(create((Axiom) node.getNodeType()));
|
568 |
256
| } else if (node.getNodeType() instanceof PredicateDefinition) {
|
569 |
40
| setLocationWithinModule(context + ".getNodeType().getPredicateDefinition()");
|
570 |
40
| n.setNodeType(create((PredicateDefinition) node.getNodeType()));
|
571 |
216
| } else if (node.getNodeType() instanceof FunctionDefinition) {
|
572 |
48
| setLocationWithinModule(context + ".getNodeType().getFunctionDefinition()");
|
573 |
48
| n.setNodeType(create((FunctionDefinition) node.getNodeType()));
|
574 |
168
| } else if (node.getNodeType() instanceof Proposition) {
|
575 |
162
| setLocationWithinModule(context + ".getNodeType().getProposition()");
|
576 |
162
| n.setNodeType(create((Proposition) node.getNodeType()));
|
577 |
6
| } else if (node.getNodeType() instanceof Rule) {
|
578 |
6
| setLocationWithinModule(context + ".getNodeType().getRule()");
|
579 |
6
| n.setNodeType(create((Rule) node.getNodeType()));
|
580 |
| } else { |
581 |
0
| throw new IllegalArgumentException("unexpected node type: "
|
582 |
| + node.getNodeType().getClass()); |
583 |
| } |
584 |
| } |
585 |
306
| if (node.getSucceedingText() != null) {
|
586 |
66
| setLocationWithinModule(context + ".getSucceedingText()");
|
587 |
66
| n.setSucceedingText(create(node.getSucceedingText()));
|
588 |
| } |
589 |
306
| setLocationWithinModule(context);
|
590 |
306
| getQedeqCreated().getModuleLabels().addNode(getCurrentContext(), n);
|
591 |
304
| return n;
|
592 |
| } |
593 |
| |
594 |
50
| private final AxiomVo create(final Axiom axiom) throws IllegalModuleDataException {
|
595 |
50
| if (axiom == null) {
|
596 |
0
| return null;
|
597 |
| } |
598 |
50
| final AxiomVo a = new AxiomVo();
|
599 |
50
| final String context = getCurrentContext().getLocationWithinModule();
|
600 |
50
| if (axiom.getFormula() != null) {
|
601 |
50
| setLocationWithinModule(context + ".getFormula()");
|
602 |
50
| a.setFormula(create(axiom.getFormula()));
|
603 |
| } |
604 |
50
| if (axiom.getDescription() != null) {
|
605 |
0
| setLocationWithinModule(context + ".getDescription()");
|
606 |
0
| a.setDescription(create(axiom.getDescription()));
|
607 |
| } |
608 |
50
| setLocationWithinModule(context);
|
609 |
50
| return a;
|
610 |
| } |
611 |
| |
612 |
40
| private final PredicateDefinitionVo create(final PredicateDefinition definition)
|
613 |
| throws IllegalModuleDataException { |
614 |
40
| if (definition == null) {
|
615 |
0
| return null;
|
616 |
| } |
617 |
40
| final PredicateDefinitionVo d = new PredicateDefinitionVo();
|
618 |
40
| final String context = getCurrentContext().getLocationWithinModule();
|
619 |
40
| if (definition.getLatexPattern() != null) {
|
620 |
40
| setLocationWithinModule(context + ".getLatexPattern()");
|
621 |
40
| d.setLatexPattern(definition.getLatexPattern());
|
622 |
| } |
623 |
40
| if (definition.getName() != null) {
|
624 |
40
| setLocationWithinModule(context + ".getName()");
|
625 |
40
| d.setName(definition.getName());
|
626 |
| } |
627 |
40
| if (definition.getArgumentNumber() != null) {
|
628 |
40
| setLocationWithinModule(context + ".getArgumentNumber()");
|
629 |
40
| d.setArgumentNumber(definition.getArgumentNumber());
|
630 |
| } |
631 |
40
| if (definition.getVariableList() != null) {
|
632 |
40
| setLocationWithinModule(context + ".getVariableList()");
|
633 |
40
| d.setVariableList(create(definition.getVariableList()));
|
634 |
| } |
635 |
40
| if (definition.getFormula() != null) {
|
636 |
32
| setLocationWithinModule(context + ".getFormula()");
|
637 |
32
| d.setFormula(create(definition.getFormula()));
|
638 |
| } |
639 |
40
| if (definition.getDescription() != null) {
|
640 |
0
| setLocationWithinModule(context + ".getDescription()");
|
641 |
0
| d.setDescription(create(definition.getDescription()));
|
642 |
| } |
643 |
40
| setLocationWithinModule(context);
|
644 |
40
| return d;
|
645 |
| } |
646 |
| |
647 |
48
| private final FunctionDefinitionVo create(final FunctionDefinition definition)
|
648 |
| throws IllegalModuleDataException { |
649 |
48
| if (definition == null) {
|
650 |
0
| return null;
|
651 |
| } |
652 |
48
| final FunctionDefinitionVo d = new FunctionDefinitionVo();
|
653 |
48
| final String context = getCurrentContext().getLocationWithinModule();
|
654 |
48
| if (definition.getLatexPattern() != null) {
|
655 |
48
| setLocationWithinModule(context + ".getLatexPattern()");
|
656 |
48
| d.setLatexPattern(definition.getLatexPattern());
|
657 |
| } |
658 |
48
| if (definition.getArgumentNumber() != null) {
|
659 |
48
| setLocationWithinModule(context + ".getArgumentNumber()");
|
660 |
48
| d.setArgumentNumber(definition.getArgumentNumber());
|
661 |
| } |
662 |
48
| if (definition.getName() != null) {
|
663 |
48
| setLocationWithinModule(context + ".getName()");
|
664 |
48
| d.setName(definition.getName());
|
665 |
| } |
666 |
48
| if (definition.getVariableList() != null) {
|
667 |
39
| setLocationWithinModule(context + ".getVariableList()");
|
668 |
39
| d.setVariableList(create(definition.getVariableList()));
|
669 |
| } |
670 |
48
| if (definition.getTerm() != null) {
|
671 |
48
| setLocationWithinModule(context + ".getTerm()");
|
672 |
48
| d.setTerm(create(definition.getTerm()));
|
673 |
| } |
674 |
48
| if (definition.getDescription() != null) {
|
675 |
0
| setLocationWithinModule(context + ".getDescription()");
|
676 |
0
| d.setDescription(create(definition.getDescription()));
|
677 |
| } |
678 |
48
| setLocationWithinModule(context);
|
679 |
48
| return d;
|
680 |
| } |
681 |
| |
682 |
162
| private final PropositionVo create(final Proposition proposition)
|
683 |
| throws IllegalModuleDataException { |
684 |
162
| if (proposition == null) {
|
685 |
0
| return null;
|
686 |
| } |
687 |
162
| final PropositionVo p = new PropositionVo();
|
688 |
162
| final String context = getCurrentContext().getLocationWithinModule();
|
689 |
162
| if (proposition.getFormula() != null) {
|
690 |
162
| setLocationWithinModule(context + ".getFormula()");
|
691 |
162
| p.setFormula(create(proposition.getFormula()));
|
692 |
| } |
693 |
162
| if (proposition.getDescription() != null) {
|
694 |
3
| setLocationWithinModule(context + ".getDescription()");
|
695 |
3
| p.setDescription(create(proposition.getDescription()));
|
696 |
| } |
697 |
162
| if (proposition.getProofList() != null) {
|
698 |
15
| setLocationWithinModule(context + ".getProofList()");
|
699 |
15
| p.setProofList(create(proposition.getProofList()));
|
700 |
| } |
701 |
162
| setLocationWithinModule(context);
|
702 |
162
| return p;
|
703 |
| } |
704 |
| |
705 |
6
| private final RuleVo create(final Rule rule)
|
706 |
| throws IllegalModuleDataException { |
707 |
6
| if (rule == null) {
|
708 |
0
| return null;
|
709 |
| } |
710 |
6
| final RuleVo r = new RuleVo();
|
711 |
6
| final String context = getCurrentContext().getLocationWithinModule();
|
712 |
6
| if (rule.getName() != null) {
|
713 |
6
| setLocationWithinModule(context + ".getName()");
|
714 |
6
| r.setName(rule.getName());
|
715 |
| } |
716 |
6
| if (rule.getLinkList() != null) {
|
717 |
3
| setLocationWithinModule(context + ".getLinkList()");
|
718 |
3
| r.setLinkList(create(rule.getLinkList()));
|
719 |
| } |
720 |
6
| if (rule.getDescription() != null) {
|
721 |
6
| setLocationWithinModule(context + ".getDescription()");
|
722 |
6
| r.setDescription(create(rule.getDescription()));
|
723 |
| } |
724 |
6
| if (rule.getProofList() != null) {
|
725 |
0
| setLocationWithinModule(context + ".getProofList()");
|
726 |
0
| r.setProofList(create(rule.getProofList()));
|
727 |
| } |
728 |
6
| setLocationWithinModule(context);
|
729 |
6
| return r;
|
730 |
| } |
731 |
| |
732 |
3
| private final LinkListVo create(final LinkList linkList) {
|
733 |
3
| if (linkList == null) {
|
734 |
0
| return null;
|
735 |
| } |
736 |
3
| final LinkListVo list = new LinkListVo();
|
737 |
3
| final String context = getCurrentContext().getLocationWithinModule();
|
738 |
3
| for (int i = 0; i < linkList.size(); i++) {
|
739 |
3
| setLocationWithinModule(context + ".get(" + i + ")");
|
740 |
3
| list.add(linkList.get(i));
|
741 |
| } |
742 |
3
| setLocationWithinModule(context);
|
743 |
3
| return list;
|
744 |
| } |
745 |
| |
746 |
79
| private final VariableListVo create(final VariableList variableList) {
|
747 |
79
| if (variableList == null) {
|
748 |
0
| return null;
|
749 |
| } |
750 |
79
| final VariableListVo list = new VariableListVo();
|
751 |
79
| final String context = getCurrentContext().getLocationWithinModule();
|
752 |
79
| for (int i = 0; i < variableList.size(); i++) {
|
753 |
117
| setLocationWithinModule(context + ".get(" + i + ")");
|
754 |
117
| list.add(create(variableList.get(i)));
|
755 |
| } |
756 |
79
| setLocationWithinModule(context);
|
757 |
79
| return list;
|
758 |
| } |
759 |
| |
760 |
15
| private final ProofListVo create(final ProofList proofList)
|
761 |
| throws IllegalModuleDataException { |
762 |
15
| if (proofList == null) {
|
763 |
0
| return null;
|
764 |
| } |
765 |
15
| final ProofListVo list = new ProofListVo();
|
766 |
15
| final String context = getCurrentContext().getLocationWithinModule();
|
767 |
15
| for (int i = 0; i < proofList.size(); i++) {
|
768 |
15
| setLocationWithinModule(context + ".get(" + i + ")");
|
769 |
15
| list.add(create(proofList.get(i)));
|
770 |
| } |
771 |
15
| setLocationWithinModule(context);
|
772 |
15
| return list;
|
773 |
| } |
774 |
| |
775 |
15
| private final ProofVo create(final Proof proof)
|
776 |
| throws IllegalModuleDataException { |
777 |
15
| if (proof == null) {
|
778 |
0
| return null;
|
779 |
| } |
780 |
15
| final ProofVo p = new ProofVo();
|
781 |
15
| final String context = getCurrentContext().getLocationWithinModule();
|
782 |
15
| if (proof.getNonFormalProof() != null) {
|
783 |
15
| setLocationWithinModule(context + ".getNonFormalProof()");
|
784 |
15
| p.setNonFormalProof(create(proof.getNonFormalProof()));
|
785 |
| } |
786 |
15
| setLocationWithinModule(context);
|
787 |
15
| return p;
|
788 |
| } |
789 |
| |
790 |
244
| private final FormulaVo create(final Formula formula) {
|
791 |
244
| if (formula == null) {
|
792 |
0
| return null;
|
793 |
| } |
794 |
244
| final FormulaVo f = new FormulaVo();
|
795 |
244
| final String context = getCurrentContext().getLocationWithinModule();
|
796 |
244
| if (formula.getElement() != null) {
|
797 |
244
| setLocationWithinModule(context + ".getElement()");
|
798 |
244
| f.setElement(create(formula.getElement()));
|
799 |
| } |
800 |
244
| setLocationWithinModule(context);
|
801 |
244
| return f;
|
802 |
| } |
803 |
| |
804 |
48
| private final TermVo create(final Term term) {
|
805 |
48
| if (term == null) {
|
806 |
0
| return null;
|
807 |
| } |
808 |
48
| final TermVo f = new TermVo();
|
809 |
48
| final String context = getCurrentContext().getLocationWithinModule();
|
810 |
48
| if (term.getElement() != null) {
|
811 |
48
| setLocationWithinModule(context + ".getElement()");
|
812 |
48
| f.setElement(create(term.getElement()));
|
813 |
| } |
814 |
48
| setLocationWithinModule(context);
|
815 |
48
| return f;
|
816 |
| } |
817 |
| |
818 |
| |
819 |
409
| private final Element create(final Element element) {
|
820 |
409
| if (element == null) {
|
821 |
0
| return null;
|
822 |
| } |
823 |
409
| return element.copy();
|
824 |
| } |
825 |
| |
826 |
| |
827 |
| |
828 |
| |
829 |
| |
830 |
| |
831 |
| |
832 |
| |
833 |
| |
834 |
| |
835 |
| |
836 |
| |
837 |
| |
838 |
| |
839 |
| |
840 |
| |
841 |
| |
842 |
| |
843 |
| |
844 |
| |
845 |
| |
846 |
| |
847 |
| |
848 |
| |
849 |
| |
850 |
| |
851 |
| |
852 |
| |
853 |
| |
854 |
| |
855 |
| |
856 |
| |
857 |
| |
858 |
| |
859 |
| |
860 |
| |
861 |
| |
862 |
| |
863 |
| |
864 |
| |
865 |
| |
866 |
| |
867 |
| |
868 |
| |
869 |
| |
870 |
| |
871 |
| |
872 |
| |
873 |
| |
874 |
1256
| private final LatexListVo create(final LatexList latexList)
|
875 |
| throws IllegalModuleDataException { |
876 |
1256
| if (latexList == null) {
|
877 |
0
| return null;
|
878 |
| } |
879 |
1256
| final LatexListVo list = new LatexListVo();
|
880 |
1256
| final String context = getCurrentContext().getLocationWithinModule();
|
881 |
1256
| for (int i = 0; i < latexList.size(); i++) {
|
882 |
2201
| setLocationWithinModule(context + ".get(" + i + ")");
|
883 |
2201
| try {
|
884 |
2201
| if (latexList.get(i) == null) {
|
885 |
0
| throw new NullPointerListEntryException(1000, "Null pointer not permitted.");
|
886 |
| } |
887 |
2201
| for (int j = 0; j < list.size(); j++) {
|
888 |
945
| if ((list.get(j)).getLanguage().equals(latexList.get(i).getLanguage())) {
|
889 |
0
| throw new DuplicateLanguageEntryException(1001,
|
890 |
| "Language entry exists already", i); |
891 |
| } |
892 |
| } |
893 |
2201
| list.add(create(latexList.get(i)));
|
894 |
| } catch (NullPointerListEntryException e) { |
895 |
0
| throw new IllegalModuleDataException(e.getErrorCode(),
|
896 |
| e.getMessage(), new ModuleContext(getCurrentContext()), e); |
897 |
| } catch (DuplicateLanguageEntryException e) { |
898 |
0
| throw new IllegalModuleDataException(e.getErrorCode(), e.getMessage(),
|
899 |
| new ModuleContext(getCurrentContext()), new ModuleContext(getCurrentContext(), |
900 |
| context + ".get(" + (e.getIndex() + 1) + ")"), e); |
901 |
| } |
902 |
| } |
903 |
1256
| setLocationWithinModule(context);
|
904 |
1256
| return list;
|
905 |
| } |
906 |
| |
907 |
| |
908 |
| |
909 |
| |
910 |
| |
911 |
| |
912 |
| |
913 |
2217
| private final LatexVo create(final Latex latex) {
|
914 |
2217
| if (latex == null) {
|
915 |
0
| return null;
|
916 |
| } |
917 |
2217
| final LatexVo lat = new LatexVo();
|
918 |
| |
919 |
2217
| lat.setLanguage(latex.getLanguage());
|
920 |
2217
| lat.setLatex(latex.getLatex());
|
921 |
2217
| return lat;
|
922 |
| } |
923 |
| |
924 |
| |
925 |
| |
926 |
| |
927 |
| |
928 |
| |
929 |
6450
| protected void setLocationWithinModule(final String locationWithinModule) {
|
930 |
6450
| getCurrentContext().setLocationWithinModule(locationWithinModule);
|
931 |
| } |
932 |
| |
933 |
| |
934 |
| |
935 |
| |
936 |
| |
937 |
| |
938 |
25437
| protected final ModuleContext getCurrentContext() {
|
939 |
25437
| return currentContext;
|
940 |
| } |
941 |
| |
942 |
| |
943 |
| |
944 |
| |
945 |
| |
946 |
| |
947 |
3150
| protected final Qedeq getQedeqOriginal() {
|
948 |
3150
| return original;
|
949 |
| } |
950 |
| |
951 |
| |
952 |
| |
953 |
| |
954 |
| |
955 |
| |
956 |
306
| protected final QedeqBo getQedeqCreated() {
|
957 |
306
| return qedeq;
|
958 |
| } |
959 |
| |
960 |
| } |