|
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
| |