|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| |
|
16 |
| |
|
17 |
| |
|
18 |
| package org.qedeq.kernel.bo.load; |
|
19 |
| |
|
20 |
| import org.qedeq.kernel.base.list.Atom; |
|
21 |
| import org.qedeq.kernel.base.list.Element; |
|
22 |
| import org.qedeq.kernel.base.list.ElementList; |
|
23 |
| import org.qedeq.kernel.base.module.Author; |
|
24 |
| import org.qedeq.kernel.base.module.AuthorList; |
|
25 |
| import org.qedeq.kernel.base.module.Axiom; |
|
26 |
| import org.qedeq.kernel.base.module.Chapter; |
|
27 |
| import org.qedeq.kernel.base.module.ChapterList; |
|
28 |
| import org.qedeq.kernel.base.module.Formula; |
|
29 |
| import org.qedeq.kernel.base.module.FunctionDefinition; |
|
30 |
| import org.qedeq.kernel.base.module.Header; |
|
31 |
| import org.qedeq.kernel.base.module.Import; |
|
32 |
| import org.qedeq.kernel.base.module.ImportList; |
|
33 |
| import org.qedeq.kernel.base.module.Latex; |
|
34 |
| import org.qedeq.kernel.base.module.LatexList; |
|
35 |
| import org.qedeq.kernel.base.module.LinkList; |
|
36 |
| import org.qedeq.kernel.base.module.LiteratureItem; |
|
37 |
| import org.qedeq.kernel.base.module.LiteratureItemList; |
|
38 |
| import org.qedeq.kernel.base.module.Location; |
|
39 |
| import org.qedeq.kernel.base.module.LocationList; |
|
40 |
| import org.qedeq.kernel.base.module.Node; |
|
41 |
| import org.qedeq.kernel.base.module.PredicateDefinition; |
|
42 |
| import org.qedeq.kernel.base.module.Proof; |
|
43 |
| import org.qedeq.kernel.base.module.ProofList; |
|
44 |
| import org.qedeq.kernel.base.module.Proposition; |
|
45 |
| import org.qedeq.kernel.base.module.Qedeq; |
|
46 |
| import org.qedeq.kernel.base.module.Rule; |
|
47 |
| import org.qedeq.kernel.base.module.Section; |
|
48 |
| import org.qedeq.kernel.base.module.SectionList; |
|
49 |
| import org.qedeq.kernel.base.module.Specification; |
|
50 |
| import org.qedeq.kernel.base.module.Subsection; |
|
51 |
| import org.qedeq.kernel.base.module.SubsectionList; |
|
52 |
| import org.qedeq.kernel.base.module.Term; |
|
53 |
| import org.qedeq.kernel.base.module.UsedByList; |
|
54 |
| import org.qedeq.kernel.base.module.VariableList; |
|
55 |
| import org.qedeq.kernel.bo.control.QedeqBoDuplicateLanguageChecker; |
|
56 |
| import org.qedeq.kernel.bo.control.QedeqBoFormalLogicChecker; |
|
57 |
| import org.qedeq.kernel.bo.module.IllegalModuleDataException; |
|
58 |
| import org.qedeq.kernel.bo.module.ModuleContext; |
|
59 |
| import org.qedeq.kernel.bo.module.ModuleDataException; |
|
60 |
| import org.qedeq.kernel.bo.module.QedeqBo; |
|
61 |
| import org.qedeq.kernel.dto.list.DefaultAtom; |
|
62 |
| import org.qedeq.kernel.dto.list.DefaultElementList; |
|
63 |
| import org.qedeq.kernel.dto.module.AuthorListVo; |
|
64 |
| import org.qedeq.kernel.dto.module.AuthorVo; |
|
65 |
| import org.qedeq.kernel.dto.module.AxiomVo; |
|
66 |
| import org.qedeq.kernel.dto.module.ChapterListVo; |
|
67 |
| import org.qedeq.kernel.dto.module.ChapterVo; |
|
68 |
| import org.qedeq.kernel.dto.module.FormulaVo; |
|
69 |
| import org.qedeq.kernel.dto.module.FunctionDefinitionVo; |
|
70 |
| import org.qedeq.kernel.dto.module.HeaderVo; |
|
71 |
| import org.qedeq.kernel.dto.module.ImportListVo; |
|
72 |
| import org.qedeq.kernel.dto.module.ImportVo; |
|
73 |
| import org.qedeq.kernel.dto.module.LatexListVo; |
|
74 |
| import org.qedeq.kernel.dto.module.LatexVo; |
|
75 |
| import org.qedeq.kernel.dto.module.LinkListVo; |
|
76 |
| import org.qedeq.kernel.dto.module.LiteratureItemListVo; |
|
77 |
| import org.qedeq.kernel.dto.module.LiteratureItemVo; |
|
78 |
| import org.qedeq.kernel.dto.module.LocationListVo; |
|
79 |
| import org.qedeq.kernel.dto.module.LocationVo; |
|
80 |
| import org.qedeq.kernel.dto.module.NodeVo; |
|
81 |
| import org.qedeq.kernel.dto.module.PredicateDefinitionVo; |
|
82 |
| import org.qedeq.kernel.dto.module.ProofListVo; |
|
83 |
| import org.qedeq.kernel.dto.module.ProofVo; |
|
84 |
| import org.qedeq.kernel.dto.module.PropositionVo; |
|
85 |
| import org.qedeq.kernel.dto.module.RuleVo; |
|
86 |
| import org.qedeq.kernel.dto.module.SectionListVo; |
|
87 |
| import org.qedeq.kernel.dto.module.SectionVo; |
|
88 |
| import org.qedeq.kernel.dto.module.SpecificationVo; |
|
89 |
| import org.qedeq.kernel.dto.module.SubsectionListVo; |
|
90 |
| import org.qedeq.kernel.dto.module.SubsectionVo; |
|
91 |
| import org.qedeq.kernel.dto.module.TermVo; |
|
92 |
| import org.qedeq.kernel.dto.module.UsedByListVo; |
|
93 |
| import org.qedeq.kernel.dto.module.VariableListVo; |
|
94 |
| |
|
95 |
| |
|
96 |
| |
|
97 |
| |
|
98 |
| |
|
99 |
| |
|
100 |
| |
|
101 |
| |
|
102 |
| |
|
103 |
| |
|
104 |
| |
|
105 |
| |
|
106 |
| |
|
107 |
| |
|
108 |
| |
|
109 |
| |
|
110 |
| public class QedeqBoFactory { |
|
111 |
| |
|
112 |
| |
|
113 |
| private DefaultQedeqBo qedeq; |
|
114 |
| |
|
115 |
| |
|
116 |
| private Qedeq original; |
|
117 |
| |
|
118 |
| |
|
119 |
| private ModuleContext currentContext; |
|
120 |
| |
|
121 |
| |
|
122 |
| |
|
123 |
| |
|
124 |
| |
|
125 |
| |
|
126 |
28
| protected QedeqBoFactory(final String globalContext) {
|
|
127 |
28
| currentContext = new ModuleContext(globalContext);
|
|
128 |
| } |
|
129 |
| |
|
130 |
| |
|
131 |
| |
|
132 |
| |
|
133 |
| |
|
134 |
| |
|
135 |
| |
|
136 |
| |
|
137 |
| |
|
138 |
| |
|
139 |
| |
|
140 |
| |
|
141 |
| |
|
142 |
| |
|
143 |
| |
|
144 |
17
| public static DefaultQedeqBo createQedeq(final String globalContext, final Qedeq original)
|
|
145 |
| throws ModuleDataException { |
|
146 |
17
| final QedeqBoFactory creator = new QedeqBoFactory(globalContext);
|
|
147 |
17
| DefaultQedeqBo bo = creator.create(original);
|
|
148 |
| |
|
149 |
| |
|
150 |
| |
|
151 |
| |
|
152 |
16
| QedeqBoFormalLogicChecker.check(globalContext, bo);
|
|
153 |
10
| QedeqBoDuplicateLanguageChecker.check(globalContext, bo);
|
|
154 |
9
| return bo;
|
|
155 |
| } |
|
156 |
| |
|
157 |
| |
|
158 |
| |
|
159 |
| |
|
160 |
| |
|
161 |
| |
|
162 |
| |
|
163 |
| |
|
164 |
| |
|
165 |
| |
|
166 |
| |
|
167 |
| |
|
168 |
| |
|
169 |
| |
|
170 |
| |
|
171 |
28
| protected final DefaultQedeqBo create(final Qedeq original) throws IllegalModuleDataException {
|
|
172 |
28
| this.original = original;
|
|
173 |
28
| getCurrentContext().setLocationWithinModule("");
|
|
174 |
28
| if (original == null) {
|
|
175 |
0
| qedeq = null;
|
|
176 |
0
| return qedeq;
|
|
177 |
| } |
|
178 |
28
| qedeq = new DefaultQedeqBo();
|
|
179 |
28
| final String context = getCurrentContext().getLocationWithinModule();
|
|
180 |
28
| if (original.getHeader() != null) {
|
|
181 |
28
| getCurrentContext().setLocationWithinModule(context + "getHeader()");
|
|
182 |
28
| qedeq.setHeader(create(original.getHeader()));
|
|
183 |
| } |
|
184 |
28
| if (original.getChapterList() != null) {
|
|
185 |
28
| getCurrentContext().setLocationWithinModule(context + "getChapterList()");
|
|
186 |
28
| qedeq.setChapterList(create(original.getChapterList()));
|
|
187 |
| } |
|
188 |
26
| if (original.getLiteratureItemList() != null) {
|
|
189 |
9
| getCurrentContext().setLocationWithinModule(context + "getLiteratureItemList()");
|
|
190 |
9
| qedeq.setLiteratureItemList(create(original.getLiteratureItemList()));
|
|
191 |
| } |
|
192 |
26
| return qedeq;
|
|
193 |
| } |
|
194 |
| |
|
195 |
| |
|
196 |
| |
|
197 |
| |
|
198 |
| |
|
199 |
| |
|
200 |
| |
|
201 |
| |
|
202 |
| |
|
203 |
| |
|
204 |
| |
|
205 |
| |
|
206 |
| |
|
207 |
| |
|
208 |
28
| private final HeaderVo create(final Header header)
|
|
209 |
| throws IllegalModuleDataException { |
|
210 |
28
| if (header == null) {
|
|
211 |
0
| return null;
|
|
212 |
| } |
|
213 |
28
| final HeaderVo h = new HeaderVo();
|
|
214 |
28
| final String context = getCurrentContext().getLocationWithinModule();
|
|
215 |
28
| if (header.getTitle() != null) {
|
|
216 |
28
| setLocationWithinModule(context + ".getTitle()");
|
|
217 |
28
| h.setTitle(create(header.getTitle()));
|
|
218 |
| } |
|
219 |
28
| if (header.getAuthorList() != null) {
|
|
220 |
28
| setLocationWithinModule(context + ".getAuthorList()");
|
|
221 |
28
| h.setAuthorList(create(header.getAuthorList()));
|
|
222 |
| } |
|
223 |
28
| if (header.getSummary() != null) {
|
|
224 |
28
| setLocationWithinModule(context + ".getSummary()");
|
|
225 |
28
| h.setSummary(create(header.getSummary()));
|
|
226 |
| } |
|
227 |
28
| if (header.getEmail() != null) {
|
|
228 |
28
| setLocationWithinModule(context + ".getEmail()");
|
|
229 |
28
| h.setEmail(header.getEmail());
|
|
230 |
| } |
|
231 |
28
| if (header.getSpecification() != null) {
|
|
232 |
28
| setLocationWithinModule(context + ".getSpecification()");
|
|
233 |
28
| h.setSpecification(create(header.getSpecification()));
|
|
234 |
| } |
|
235 |
28
| if (header.getImportList() != null) {
|
|
236 |
15
| setLocationWithinModule(context + ".getImportList()");
|
|
237 |
15
| h.setImportList(create(header.getImportList()));
|
|
238 |
| } |
|
239 |
28
| if (header.getUsedByList() != null) {
|
|
240 |
12
| setLocationWithinModule(context + ".getUsedByList()");
|
|
241 |
12
| h.setUsedByList(create(header.getUsedByList()));
|
|
242 |
| } |
|
243 |
28
| setLocationWithinModule(context);
|
|
244 |
28
| return h;
|
|
245 |
| } |
|
246 |
| |
|
247 |
| |
|
248 |
| |
|
249 |
| |
|
250 |
| |
|
251 |
| |
|
252 |
| |
|
253 |
| |
|
254 |
| |
|
255 |
| |
|
256 |
| |
|
257 |
| |
|
258 |
| |
|
259 |
12
| private final UsedByListVo create(final UsedByList usedByList) {
|
|
260 |
12
| if (usedByList == null) {
|
|
261 |
0
| return null;
|
|
262 |
| } |
|
263 |
12
| final String context = getCurrentContext().getLocationWithinModule();
|
|
264 |
12
| final UsedByListVo list = new UsedByListVo();
|
|
265 |
12
| for (int i = 0; i < usedByList.size(); i++) {
|
|
266 |
12
| setLocationWithinModule(context + ".get(" + i + ")");
|
|
267 |
12
| list.add(create(usedByList.get(i)));
|
|
268 |
| } |
|
269 |
12
| setLocationWithinModule(context);
|
|
270 |
12
| return list;
|
|
271 |
| } |
|
272 |
| |
|
273 |
15
| private final ImportListVo create(final ImportList importList) {
|
|
274 |
15
| if (importList == null) {
|
|
275 |
0
| return null;
|
|
276 |
| } |
|
277 |
15
| final String context = getCurrentContext().getLocationWithinModule();
|
|
278 |
15
| final ImportListVo list = new ImportListVo();
|
|
279 |
15
| for (int i = 0; i < importList.size(); i++) {
|
|
280 |
24
| setLocationWithinModule(context + ".get(" + i + ")");
|
|
281 |
24
| list.add(create(importList.get(i)));
|
|
282 |
| } |
|
283 |
15
| setLocationWithinModule(context);
|
|
284 |
15
| return list;
|
|
285 |
| } |
|
286 |
| |
|
287 |
24
| private final ImportVo create(final Import imp) {
|
|
288 |
24
| if (imp == null) {
|
|
289 |
0
| return null;
|
|
290 |
| } |
|
291 |
24
| final ImportVo i = new ImportVo();
|
|
292 |
24
| final String context = getCurrentContext().getLocationWithinModule();
|
|
293 |
24
| if (imp.getLabel() != null) {
|
|
294 |
24
| setLocationWithinModule(context + ".getLabel()");
|
|
295 |
24
| i.setLabel(imp.getLabel());
|
|
296 |
| } |
|
297 |
24
| if (imp.getSpecification() != null) {
|
|
298 |
24
| setLocationWithinModule(context + ".getSpecification()");
|
|
299 |
24
| i.setSpecification(create(imp.getSpecification()));
|
|
300 |
| } |
|
301 |
24
| setLocationWithinModule(context);
|
|
302 |
24
| return i;
|
|
303 |
| } |
|
304 |
| |
|
305 |
64
| private final SpecificationVo create(final Specification specification) {
|
|
306 |
64
| if (specification == null) {
|
|
307 |
0
| return null;
|
|
308 |
| } |
|
309 |
64
| final SpecificationVo s = new SpecificationVo();
|
|
310 |
64
| final String context = getCurrentContext().getLocationWithinModule();
|
|
311 |
64
| if (specification.getName() != null) {
|
|
312 |
64
| setLocationWithinModule(context + ".getName()");
|
|
313 |
64
| s.setName(specification.getName());
|
|
314 |
| } |
|
315 |
64
| if (specification.getRuleVersion() != null) {
|
|
316 |
64
| setLocationWithinModule(context + ".getRuleVersion()");
|
|
317 |
64
| s.setRuleVersion(specification.getRuleVersion());
|
|
318 |
| } |
|
319 |
64
| if (specification.getLocationList() != null) {
|
|
320 |
64
| setLocationWithinModule(context + ".getLocationList()");
|
|
321 |
64
| s.setLocationList(create(specification.getLocationList()));
|
|
322 |
| } |
|
323 |
64
| setLocationWithinModule(context);
|
|
324 |
64
| return s;
|
|
325 |
| } |
|
326 |
| |
|
327 |
64
| private final LocationListVo create(final LocationList locationList) {
|
|
328 |
64
| if (locationList == null) {
|
|
329 |
0
| return null;
|
|
330 |
| } |
|
331 |
64
| final LocationListVo list = new LocationListVo();
|
|
332 |
64
| final String context = getCurrentContext().getLocationWithinModule();
|
|
333 |
64
| for (int i = 0; i < locationList.size(); i++) {
|
|
334 |
64
| setLocationWithinModule(context + ".get(" + i + ")");
|
|
335 |
64
| list.add(create(locationList.get(i)));
|
|
336 |
| } |
|
337 |
64
| setLocationWithinModule(context);
|
|
338 |
64
| return list;
|
|
339 |
| } |
|
340 |
| |
|
341 |
64
| private final LocationVo create(final Location location) {
|
|
342 |
64
| if (location == null) {
|
|
343 |
0
| return null;
|
|
344 |
| } |
|
345 |
64
| final LocationVo loc = new LocationVo();
|
|
346 |
64
| final String context = getCurrentContext().getLocationWithinModule();
|
|
347 |
64
| if (location.getLocation() != null) {
|
|
348 |
64
| setLocationWithinModule(context + ".getLocation()");
|
|
349 |
64
| loc.setLocation(location.getLocation());
|
|
350 |
| } |
|
351 |
64
| setLocationWithinModule(context);
|
|
352 |
64
| return loc;
|
|
353 |
| } |
|
354 |
| |
|
355 |
28
| private final AuthorListVo create(final AuthorList authorList) {
|
|
356 |
28
| if (authorList == null) {
|
|
357 |
0
| return null;
|
|
358 |
| } |
|
359 |
28
| final AuthorListVo list = new AuthorListVo();
|
|
360 |
28
| final String context = getCurrentContext().getLocationWithinModule();
|
|
361 |
28
| for (int i = 0; i < authorList.size(); i++) {
|
|
362 |
28
| setLocationWithinModule(context + ".get(" + i + ")");
|
|
363 |
28
| list.add(create(authorList.get(i)));
|
|
364 |
| } |
|
365 |
28
| setLocationWithinModule(context);
|
|
366 |
28
| return list;
|
|
367 |
| } |
|
368 |
| |
|
369 |
28
| private final AuthorVo create(final Author author) {
|
|
370 |
28
| if (author == null) {
|
|
371 |
0
| return null;
|
|
372 |
| } |
|
373 |
28
| final AuthorVo a = new AuthorVo();
|
|
374 |
28
| final String context = getCurrentContext().getLocationWithinModule();
|
|
375 |
28
| if (author.getName() != null) {
|
|
376 |
28
| setLocationWithinModule(context + ".getName()");
|
|
377 |
28
| a.setName(create(author.getName()));
|
|
378 |
| } |
|
379 |
28
| if (author.getEmail() != null) {
|
|
380 |
28
| setLocationWithinModule(context + ".getEmail()");
|
|
381 |
28
| a.setEmail(author.getEmail());
|
|
382 |
| } |
|
383 |
28
| setLocationWithinModule(context);
|
|
384 |
28
| return a;
|
|
385 |
| } |
|
386 |
| |
|
387 |
28
| private final ChapterListVo create(final ChapterList chapterList)
|
|
388 |
| throws IllegalModuleDataException { |
|
389 |
28
| if (chapterList == null) {
|
|
390 |
0
| return null;
|
|
391 |
| } |
|
392 |
28
| final ChapterListVo list = new ChapterListVo();
|
|
393 |
28
| final String context = getCurrentContext().getLocationWithinModule();
|
|
394 |
28
| for (int i = 0; i < chapterList.size(); i++) {
|
|
395 |
121
| setLocationWithinModule(context + ".get(" + i + ")");
|
|
396 |
121
| list.add(create(chapterList.get(i)));
|
|
397 |
| } |
|
398 |
26
| setLocationWithinModule(context);
|
|
399 |
26
| return list;
|
|
400 |
| } |
|
401 |
| |
|
402 |
121
| private final ChapterVo create(final Chapter chapter)
|
|
403 |
| throws IllegalModuleDataException { |
|
404 |
121
| if (chapter == null) {
|
|
405 |
0
| return null;
|
|
406 |
| } |
|
407 |
121
| final ChapterVo c = new ChapterVo();
|
|
408 |
121
| final String context = getCurrentContext().getLocationWithinModule();
|
|
409 |
121
| if (chapter.getTitle() != null) {
|
|
410 |
121
| setLocationWithinModule(context + ".getTitle()");
|
|
411 |
121
| c.setTitle(create(chapter.getTitle()));
|
|
412 |
| } |
|
413 |
121
| if (chapter.getNoNumber() != null) {
|
|
414 |
38
| setLocationWithinModule(context + ".getNoNumber()");
|
|
415 |
38
| c.setNoNumber(chapter.getNoNumber());
|
|
416 |
| } |
|
417 |
121
| if (chapter.getIntroduction() != null) {
|
|
418 |
118
| setLocationWithinModule(context + ".getIntroduction()");
|
|
419 |
118
| c.setIntroduction(create(chapter.getIntroduction()));
|
|
420 |
| } |
|
421 |
121
| if (chapter.getSectionList() != null) {
|
|
422 |
75
| setLocationWithinModule(context + ".getSectionList()");
|
|
423 |
75
| c.setSectionList(create(chapter.getSectionList()));
|
|
424 |
| } |
|
425 |
119
| setLocationWithinModule(context);
|
|
426 |
119
| return c;
|
|
427 |
| } |
|
428 |
| |
|
429 |
9
| private LiteratureItemListVo create(final LiteratureItemList literatureItemList)
|
|
430 |
| throws IllegalModuleDataException { |
|
431 |
9
| if (literatureItemList == null) {
|
|
432 |
0
| return null;
|
|
433 |
| } |
|
434 |
9
| final LiteratureItemListVo list = new LiteratureItemListVo();
|
|
435 |
9
| final String context = getCurrentContext().getLocationWithinModule();
|
|
436 |
9
| for (int i = 0; i < literatureItemList.size(); i++) {
|
|
437 |
39
| setLocationWithinModule(context + ".get(" + i + ")");
|
|