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