|
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.elli.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.FormulaOrTerm; |
|
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.UsedByList; |
|
51 |
| import org.qedeq.kernel.base.module.VariableList; |
|
52 |
| import org.qedeq.kernel.bo.module.AuthorBo; |
|
53 |
| import org.qedeq.kernel.bo.module.AuthorListBo; |
|
54 |
| import org.qedeq.kernel.bo.module.AxiomBo; |
|
55 |
| import org.qedeq.kernel.bo.module.ChapterBo; |
|
56 |
| import org.qedeq.kernel.bo.module.ChapterListBo; |
|
57 |
| import org.qedeq.kernel.bo.module.DuplicateLanguageEntryException; |
|
58 |
| import org.qedeq.kernel.bo.module.FormulaOrTermBo; |
|
59 |
| import org.qedeq.kernel.bo.module.FunctionDefinitionBo; |
|
60 |
| import org.qedeq.kernel.bo.module.HeaderBo; |
|
61 |
| import org.qedeq.kernel.bo.module.ImportBo; |
|
62 |
| import org.qedeq.kernel.bo.module.ImportListBo; |
|
63 |
| import org.qedeq.kernel.bo.module.LatexBo; |
|
64 |
| import org.qedeq.kernel.bo.module.LatexListBo; |
|
65 |
| import org.qedeq.kernel.bo.module.LinkListBo; |
|
66 |
| import org.qedeq.kernel.bo.module.LiteratureItemBo; |
|
67 |
| import org.qedeq.kernel.bo.module.LiteratureItemListBo; |
|
68 |
| import org.qedeq.kernel.bo.module.LocationBo; |
|
69 |
| import org.qedeq.kernel.bo.module.LocationListBo; |
|
70 |
| import org.qedeq.kernel.bo.module.NodeBo; |
|
71 |
| import org.qedeq.kernel.bo.module.NullPointerListEntryException; |
|
72 |
| import org.qedeq.kernel.bo.module.PredicateDefinitionBo; |
|
73 |
| import org.qedeq.kernel.bo.module.ProofBo; |
|
74 |
| import org.qedeq.kernel.bo.module.ProofListBo; |
|
75 |
| import org.qedeq.kernel.bo.module.PropositionBo; |
|
76 |
| import org.qedeq.kernel.bo.module.QedeqBo; |
|
77 |
| import org.qedeq.kernel.bo.module.RuleBo; |
|
78 |
| import org.qedeq.kernel.bo.module.SectionBo; |
|
79 |
| import org.qedeq.kernel.bo.module.SectionListBo; |
|
80 |
| import org.qedeq.kernel.bo.module.SpecificationBo; |
|
81 |
| import org.qedeq.kernel.bo.module.SubsectionBo; |
|
82 |
| import org.qedeq.kernel.bo.module.SubsectionListBo; |
|
83 |
| import org.qedeq.kernel.bo.module.UsedByListBo; |
|
84 |
| import org.qedeq.kernel.bo.module.VariableListBo; |
|
85 |
| |
|
86 |
| |
|
87 |
| |
|
88 |
| |
|
89 |
| |
|
90 |
| |
|
91 |
| |
|
92 |
| |
|
93 |
| |
|
94 |
| |
|
95 |
| public class QedeqBoFactory { |
|
96 |
| |
|
97 |
| |
|
98 |
| private QedeqBo qedeq; |
|
99 |
| |
|
100 |
| |
|
101 |
| private Qedeq original; |
|
102 |
| |
|
103 |
| |
|
104 |
| private ModuleContext currentContext; |
|
105 |
| |
|
106 |
| |
|
107 |
| |
|
108 |
| |
|
109 |
| |
|
110 |
| |
|
111 |
14
| protected QedeqBoFactory(final String globalContext) {
|
|
112 |
14
| currentContext = new ModuleContext(globalContext);
|
|
113 |
| } |
|
114 |
| |
|
115 |
| |
|
116 |
| |
|
117 |
| |
|
118 |
| |
|
119 |
| |
|
120 |
| |
|
121 |
| |
|
122 |
| |
|
123 |
| |
|
124 |
| |
|
125 |
| |
|
126 |
| |
|
127 |
| |
|
128 |
| |
|
129 |
9
| public static QedeqBo createQedeq(final String globalContext, final Qedeq original)
|
|
130 |
| throws IllegalModuleDataException { |
|
131 |
9
| final QedeqBoFactory creator = new QedeqBoFactory(globalContext);
|
|
132 |
9
| return creator.create(original);
|
|
133 |
| } |
|
134 |
| |
|
135 |
| |
|
136 |
| |
|
137 |
| |
|
138 |
| |
|
139 |
| |
|
140 |
| |
|
141 |
| |
|
142 |
| |
|
143 |
| |
|
144 |
| |
|
145 |
| |
|
146 |
| |
|
147 |
| |
|
148 |
14
| protected final QedeqBo create(final Qedeq original) throws IllegalModuleDataException {
|
|
149 |
14
| this.original = original;
|
|
150 |
14
| getCurrentContext().setLocationWithinModule("");
|
|
151 |
14
| if (original == null) {
|
|
152 |
0
| qedeq = null;
|
|
153 |
0
| return qedeq;
|
|
154 |
| } |
|
155 |
14
| qedeq = new QedeqBo();
|
|
156 |
14
| final String context = getCurrentContext().getLocationWithinModule();
|
|
157 |
14
| if (original.getHeader() != null) {
|
|
158 |
14
| getCurrentContext().setLocationWithinModule(context + "getHeader()");
|
|
159 |
14
| qedeq.setHeader(create(original.getHeader()));
|
|
160 |
| } |
|
161 |
14
| if (original.getChapterList() != null) {
|
|
162 |
14
| getCurrentContext().setLocationWithinModule(context + "getChapterList()");
|
|
163 |
14
| qedeq.setChapterList(create(original.getChapterList()));
|
|
164 |
| } |
|
165 |
12
| if (original.getLiteratureItemList() != null) {
|
|
166 |
6
| getCurrentContext().setLocationWithinModule(context + "getLiteratureItemList()");
|
|
167 |
6
| qedeq.setLiteratureItemList(create(original.getLiteratureItemList()));
|
|
168 |
| } |
|
169 |
12
| return qedeq;
|
|
170 |
| } |
|
171 |
| |
|
172 |
| |
|
173 |
| |
|
174 |
| |
|
175 |
| |
|
176 |
| |
|
177 |
| |
|
178 |
| |
|
179 |
| |
|
180 |
| |
|
181 |
| |
|
182 |
| |
|
183 |
| |
|
184 |
| |
|
185 |
14
| private final HeaderBo create(final Header header)
|
|
186 |
| throws IllegalModuleDataException { |
|
187 |
14
| if (header == null) {
|
|
188 |
0
| return null;
|
|
189 |
| } |
|
190 |
14
| final HeaderBo h = new HeaderBo();
|
|
191 |
14
| final String context = getCurrentContext().getLocationWithinModule();
|
|
192 |
14
| if (header.getTitle() != null) {
|
|
193 |
14
| setLocationWithinModule(context + ".getTitle()");
|
|
194 |
14
| h.setTitle(create(header.getTitle()));
|
|
195 |
| } |
|
196 |
14
| if (header.getAuthorList() != null) {
|
|
197 |
14
| setLocationWithinModule(context + ".getAuthorList()");
|
|
198 |
14
| h.setAuthorList(create(header.getAuthorList()));
|
|
199 |
| } |
|
200 |
14
| if (header.getSummary() != null) {
|
|
201 |
14
| setLocationWithinModule(context + ".getSummary()");
|
|
202 |
14
| h.setSummary(create(header.getSummary()));
|
|
203 |
| } |
|
204 |
14
| if (header.getEmail() != null) {
|
|
205 |
0
| setLocationWithinModule(context + ".getEmail()");
|
|
206 |
0
| h.setEmail(header.getEmail());
|
|
207 |
| } |
|
208 |
14
| if (header.getSpecification() != null) {
|
|
209 |
14
| setLocationWithinModule(context + ".getSpecification()");
|
|
210 |
14
| h.setSpecification(create(header.getSpecification()));
|
|
211 |
| } |
|
212 |
14
| if (header.getImportList() != null) {
|
|
213 |
8
| setLocationWithinModule(context + ".getImportList()");
|
|
214 |
8
| h.setImportList(create(header.getImportList()));
|
|
215 |
| } |
|
216 |
14
| if (header.getUsedByList() != null) {
|
|
217 |
5
| setLocationWithinModule(context + ".getUsedByList()");
|
|
218 |
5
| h.setUsedByList(create(header.getUsedByList()));
|
|
219 |
| } |
|
220 |
14
| return h;
|
|
221 |
| } |
|
222 |
| |
|
223 |
| |
|
224 |
| |
|
225 |
| |
|
226 |
| |
|
227 |
| |
|
228 |
| |
|
229 |
| |
|
230 |
| |
|
231 |
| |
|
232 |
| |
|
233 |
| |
|
234 |
| |
|
235 |
5
| private final UsedByListBo create(final UsedByList usedByList) {
|
|
236 |
5
| if (usedByList == null) {
|
|
237 |
0
| return null;
|
|
238 |
| } |
|
239 |
5
| final String context = getCurrentContext().getLocationWithinModule();
|
|
240 |
5
| final UsedByListBo list = new UsedByListBo();
|
|
241 |
5
| for (int i = 0; i < usedByList.size(); i++) {
|
|
242 |
5
| setLocationWithinModule(context + ".get(" + i + ")");
|
|
243 |
5
| list.add(create(usedByList.get(i)));
|
|
244 |
| } |
|
245 |
5
| return list;
|
|
246 |
| } |
|
247 |
| |
|
248 |
8
| private final ImportListBo create(final ImportList importList) {
|
|
249 |
8
| if (importList == null) {
|
|
250 |
0
| return null;
|
|
251 |
| } |
|
252 |
8
| final String context = getCurrentContext().getLocationWithinModule();
|
|
253 |
8
| final ImportListBo list = new ImportListBo();
|
|
254 |
8
| for (int i = 0; i < importList.size(); i++) {
|
|
255 |
13
| setLocationWithinModule(context + ".get(" + i + ")");
|
|
256 |
13
| list.add(create(importList.get(i)));
|
|
257 |
| } |
|
258 |
8
| return list;
|
|
259 |
| } |
|
260 |
| |
|
261 |
13
| private final ImportBo create(final Import imp) {
|
|
262 |
13
| if (imp == null) {
|
|
263 |
0
| return null;
|
|
264 |
| } |
|
265 |
13
| final ImportBo i = new ImportBo();
|
|
266 |
13
| final String context = getCurrentContext().getLocationWithinModule();
|
|
267 |
13
| if (imp.getLabel() != null) {
|
|
268 |
13
| setLocationWithinModule(context + ".getLabel()");
|
|
269 |
13
| i.setLabel(imp.getLabel());
|
|
270 |
| } |
|
271 |
13
| if (imp.getSpecification() != null) {
|
|
272 |
13
| setLocationWithinModule(context + ".getSpecification()");
|
|
273 |
13
| i.setSpecification(create(imp.getSpecification()));
|
|
274 |
| } |
|
275 |
13
| return i;
|
|
276 |
| } |
|
277 |
| |
|
278 |
32
| private final SpecificationBo create(final Specification specification) {
|
|
279 |
32
| if (specification == null) {
|
|
280 |
0
| return null;
|
|
281 |
| } |
|
282 |
32
| final SpecificationBo s = new SpecificationBo();
|
|
283 |
32
| final String context = getCurrentContext().getLocationWithinModule();
|
|
284 |
32
| if (specification.getName() != null) {
|
|
285 |
19
| setLocationWithinModule(context + ".getName()");
|
|
286 |
19
| s.setName(specification.getName());
|
|
287 |
| } |
|
288 |
32
| if (specification.getRuleVersion() != null) {
|
|
289 |
19
| setLocationWithinModule(context + ".getRuleVersion()");
|
|
290 |
19
| s.setRuleVersion(specification.getRuleVersion());
|
|
291 |
| } |
|
292 |
32
| if (specification.getLocationList() != null) {
|
|
293 |
32
| setLocationWithinModule(context + ".getLocationList()");
|
|
294 |
32
| s.setLocationList(create(specification.getLocationList()));
|
|
295 |
| } |
|
296 |
32
| return s;
|
|
297 |
| } |
|
298 |
| |
|
299 |
32
| private final LocationListBo create(final LocationList locationList) {
|
|
300 |
32
| if (locationList == null) {
|
|
301 |
0
| return null;
|
|
302 |
| } |
|
303 |
32
| final LocationListBo list = new LocationListBo();
|
|
304 |
32
| final String context = getCurrentContext().getLocationWithinModule();
|
|
305 |
32
| for (int i = 0; i < locationList.size(); i++) {
|
|
306 |
32
| setLocationWithinModule(context + ".get(" + i + ")");
|
|
307 |
32
| list.add(create(locationList.get(i)));
|
|
308 |
| } |
|
309 |
32
| return list;
|
|
310 |
| } |
|
311 |
| |
|
312 |
32
| private final LocationBo create(final Location location) {
|
|
313 |
32
| if (location == null) {
|
|
314 |
0
| return null;
|
|
315 |
| } |
|
316 |
32
| final LocationBo loc = new LocationBo();
|
|
317 |
32
| final String context = getCurrentContext().getLocationWithinModule();
|
|
318 |
32
| if (location.getLocation() != null) {
|
|
319 |
32
| setLocationWithinModule(context + ".getLocation()");
|
|
320 |
32
| loc.setLocation(location.getLocation());
|
|
321 |
| } |
|
322 |
32
| return loc;
|
|
323 |
| } |
|
324 |
| |
|
325 |
14
| private final AuthorListBo create(final AuthorList authorList) {
|
|
326 |
14
| if (authorList == null) {
|
|
327 |
0
| return null;
|
|
328 |
| } |
|
329 |
14
| final AuthorListBo list = new AuthorListBo();
|
|
330 |
14
| final String context = getCurrentContext().getLocationWithinModule();
|
|
331 |
14
| for (int i = 0; i < authorList.size(); i++) {
|
|
332 |
14
| setLocationWithinModule(context + ".get(" + i + ")");
|
|
333 |
14
| list.add(create(authorList.get(i)));
|
|
334 |
| } |
|
335 |
14
| return list;
|
|
336 |
| } |
|
337 |
| |
|
338 |
14
| private final AuthorBo create(final Author author) {
|
|
339 |
14
| if (author == null) {
|
|
340 |
0
| return null;
|
|
341 |
| } |
|
342 |
14
| final AuthorBo a = new AuthorBo();
|
|
343 |
14
| final String context = getCurrentContext().getLocationWithinModule();
|
|
344 |
14
| if (author.getName() != null) {
|
|
345 |
14
| setLocationWithinModule(context + ".getName()");
|
|
346 |
14
| a.setName(create(author.getName()));
|
|
347 |
| } |
|
348 |
14
| if (author.getEmail() != null) {
|
|
349 |
14
| setLocationWithinModule(context + ".getEmail()");
|
|
350 |
14
| a.setEmail(author.getEmail());
|
|
351 |
| } |
|
352 |
14
| return a;
|
|
353 |
| } |
|
354 |
| |
|
355 |
14
| private final ChapterListBo create(final ChapterList chapterList)
|
|
356 |
| throws IllegalModuleDataException { |
|
357 |
14
| if (chapterList == null) {
|
|
358 |
0
| return null;
|
|
359 |
| } |
|
360 |
14
| final ChapterListBo list = new ChapterListBo();
|
|
361 |
14
| final String context = getCurrentContext().getLocationWithinModule();
|
|
362 |
14
| for (int i = 0; i < chapterList.size(); i++) {
|
|
363 |
71
| setLocationWithinModule(context + ".get(" + i + ")");
|
|
364 |
71
| list.add(create(chapterList.get(i)));
|
|
365 |
| } |
|
366 |
12
| return list;
|
|
367 |
| } |
|
368 |
| |
|
369 |
71
| private final ChapterBo create(final Chapter chapter)
|
|
370 |
| throws IllegalModuleDataException { |
|
371 |
71
| if (chapter == null) {
|
|
372 |
0
| return null;
|
|
373 |
| } |
|
374 |
71
| final ChapterBo c = new ChapterBo();
|
|
375 |
71
| final String context = getCurrentContext().getLocationWithinModule();
|
|
376 |
71
| if (chapter.getTitle() != null) {
|
|
377 |
71
| setLocationWithinModule(context + ".getTitle()");
|
|
378 |
71
| c.setTitle(create(chapter.getTitle()));
|
|
379 |
| } |
|
380 |
71
| if (chapter.getNoNumber() != null) {
|
|
381 |
23
| setLocationWithinModule(context + ".getNoNumber()");
|
|
382 |
23
| c.setNoNumber(chapter.getNoNumber());
|
|
383 |
| } |
|
384 |
71
| if (chapter.getIntroduction() != null) {
|
|
385 |
71
| setLocationWithinModule(context + ".getIntroduction()");
|
|
386 |
71
| c.setIntroduction(create(chapter.getIntroduction()));
|
|
387 |
| } |
|
388 |
71
| if (chapter.getSectionList() != null) {
|
|
389 |
41
| setLocationWithinModule(context + ".getSectionList()");
|
|
390 |
41
| c.setSectionList(create(chapter.getSectionList()));
|
|
391 |
| } |
|
392 |
69
| return c;
|
|
393 |
| } |
|
394 |
| |
|
395 |
6
| private LiteratureItemList create(final LiteratureItemList literatureItemList)
|
|
396 |
| throws IllegalModuleDataException { |
|
397 |
6
| if (literatureItemList == null) {
|
|
398 |
0
| return null;
|
|
399 |
| } |
|
400 |
6
| final LiteratureItemListBo list = new LiteratureItemListBo();
|
|
401 |
6
| final String context = getCurrentContext().getLocationWithinModule();
|
|
402 |
6
| for (int i = 0; i < literatureItemList.size(); i++) {
|
|
403 |
27
| setLocationWithinModule(context + ".get(" + i + ")");
|
|
404 |
27
| list.add(create(literatureItemList.get(i)));
|
|
405 |
| } |
|
406 |
6
| return list;
|
|
407 |
| } |
|
408 |
| |
|
409 |
27
| private LiteratureItem create(final LiteratureItem item)
|
|
410 |
| throws IllegalModuleDataException { |
|
411 |
27
| if (item == null) {
|
|
412 |
0
| return null;
|
|
413 |
| } |
|
414 |
27
| final LiteratureItemBo it = new LiteratureItemBo();
|
|
415 |
27
| final String context = getCurrentContext().getLocationWithinModule();
|
|
416 |
27
| if (item.getLabel() != null) {
|
|
417 |
27
| setLocationWithinModule(context + ".getLabel()");
|
|
418 |
27
| it.setLabel(item.getLabel());
|
|
419 |
| } |
|
420 |
27
| if (item.getItem() != null) {
|
|
421 |
27
| setLocationWithinModule(context + ".getItem()");
|
|
422 |
27
| it.setItem(create(item.getItem()));
|
|
423 |
| } |
|
424 |
27
| return it;
|
|
425 |
| |
|
426 |
| } |
|
427 |
| |
|
428 |
41
| private final SectionListBo create(final SectionList sectionList)
|
|
429 |
| throws IllegalModuleDataException { |
|
430 |
41
| if (sectionList == null) {
|
|
431 |
0
| return null;
|
|
432 |
| } |
|
433 |
41
| final SectionListBo list = new SectionListBo();
|
|
434 |
41
| final String context = getCurrentContext().getLocationWithinModule();
|
|
435 |
41
| for (int i = 0; i < sectionList.size(); i++) {
|
|
4 |