Clover coverage report - QedeqKernelSe Coverage Report
Coverage timestamp: So Mrz 11 2007 07:05:19 CET
file stats: LOC: 934   Methods: 41
NCLOC: 766   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
QedeqBoFactory.java 66,3% 89,3% 100% 82,6%
coverage coverage
 1    /* $Id: QedeqBoFactory.java,v 1.28 2007/03/11 01:19:34 m31 Exp $
 2    *
 3    * This file is part of the project "Hilbert II" - http://www.qedeq.org
 4    *
 5    * Copyright 2000-2007, Michael Meyling <mime@qedeq.org>.
 6    *
 7    * "Hilbert II" is free software; you can redistribute
 8    * it and/or modify it under the terms of the GNU General Public
 9    * License as published by the Free Software Foundation; either
 10    * version 2 of the License, or (at your option) any later version.
 11    *
 12    * This program is distributed in the hope that it will be useful,
 13    * but WITHOUT ANY WARRANTY; without even the implied warranty of
 14    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 15    * GNU General Public License for more details.
 16    */
 17   
 18    package org.qedeq.kernel.bo.control;
 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.module.IllegalModuleDataException;
 56    import org.qedeq.kernel.bo.module.ModuleDataException;
 57    import org.qedeq.kernel.bo.module.QedeqBo;
 58    import org.qedeq.kernel.context.ModuleContext;
 59    import org.qedeq.kernel.dto.list.AtomImpl;
 60    import org.qedeq.kernel.dto.list.ElementListImpl;
 61    import org.qedeq.kernel.dto.module.AuthorListVo;
 62    import org.qedeq.kernel.dto.module.AuthorVo;
 63    import org.qedeq.kernel.dto.module.AxiomVo;
 64    import org.qedeq.kernel.dto.module.ChapterListVo;
 65    import org.qedeq.kernel.dto.module.ChapterVo;
 66    import org.qedeq.kernel.dto.module.FormulaVo;
 67    import org.qedeq.kernel.dto.module.FunctionDefinitionVo;
 68    import org.qedeq.kernel.dto.module.HeaderVo;
 69    import org.qedeq.kernel.dto.module.ImportListVo;
 70    import org.qedeq.kernel.dto.module.ImportVo;
 71    import org.qedeq.kernel.dto.module.LatexListVo;
 72    import org.qedeq.kernel.dto.module.LatexVo;
 73    import org.qedeq.kernel.dto.module.LinkListVo;
 74    import org.qedeq.kernel.dto.module.LiteratureItemListVo;
 75    import org.qedeq.kernel.dto.module.LiteratureItemVo;
 76    import org.qedeq.kernel.dto.module.LocationListVo;
 77    import org.qedeq.kernel.dto.module.LocationVo;
 78    import org.qedeq.kernel.dto.module.NodeVo;
 79    import org.qedeq.kernel.dto.module.PredicateDefinitionVo;
 80    import org.qedeq.kernel.dto.module.ProofListVo;
 81    import org.qedeq.kernel.dto.module.ProofVo;
 82    import org.qedeq.kernel.dto.module.PropositionVo;
 83    import org.qedeq.kernel.dto.module.RuleVo;
 84    import org.qedeq.kernel.dto.module.SectionListVo;
 85    import org.qedeq.kernel.dto.module.SectionVo;
 86    import org.qedeq.kernel.dto.module.SpecificationVo;
 87    import org.qedeq.kernel.dto.module.SubsectionListVo;
 88    import org.qedeq.kernel.dto.module.SubsectionVo;
 89    import org.qedeq.kernel.dto.module.TermVo;
 90    import org.qedeq.kernel.dto.module.UsedByListVo;
 91    import org.qedeq.kernel.dto.module.VariableListVo;
 92   
 93   
 94    /**
 95    * A factory for creating {@link org.qedeq.kernel.bo.module.QedeqBo}s.
 96    *
 97    * LATER mime 20050707: use director pattern or transfer creation methods
 98    * into BOs or use visitor pattern
 99    * @version $Revision: 1.28 $
 100    * @author Michael Meyling
 101    */
 102    public class QedeqBoFactory {
 103   
 104    /** Qedeq module business object. */
 105    private QedeqBo qedeq;
 106   
 107    /** Qedeq module input object. */
 108    private Qedeq original;
 109   
 110    /** Current context during creation. */
 111    private ModuleContext currentContext;
 112   
 113    /**
 114    * Constructor.
 115    *
 116    * @param globalContext Module location information.
 117    */
 118  32 protected QedeqBoFactory(final String globalContext) {
 119  32 currentContext = new ModuleContext(globalContext);
 120    }
 121   
 122    /**
 123    * Create {@link QedeqBo} out of an {@link Qedeq} instance.
 124    * During that procedure some basic checking is done. E.g. the uniqueness of entries
 125    * is tested. The resulting business object has no references to the original
 126    * {@link Qedeq} instance.
 127    * <p>
 128    * During the creation process the caller must assert that no modifications are made
 129    * to the {@link Qedeq} instance including its referenced objects.
 130    *
 131    * @param globalContext Module location information.
 132    * @param original Basic QEDEQ module object.
 133    * @return Filled QEDEQ business object. Is equal to the parameter <code>qedeq</code>.
 134    * @throws ModuleDataException Invalid data found.
 135    */
 136  21 public static QedeqBo createQedeq(final String globalContext, final Qedeq original)
 137    throws ModuleDataException {
 138  21 final QedeqBoFactory creator = new QedeqBoFactory(globalContext);
 139  21 QedeqBo bo = creator.create(original);
 140   
 141    // TODO mime 20070305: just for testing purpose the following two checks are
 142    // integrated here in the BO creation. The checking results should be maintained
 143    // later on as additional information to a module (e.g. globalContext?).
 144  20 QedeqBoFormalLogicChecker.check(globalContext, bo);
 145  14 QedeqBoDuplicateLanguageChecker.check(globalContext, bo);
 146  13 return bo;
 147    }
 148   
 149    /**
 150    * Create {@link QedeqBo} out of an {@link Qedeq} instance.
 151    * During that procedure some basic checking is done. E.g. the uniqueness of entries
 152    * is tested. The resulting business object has no references to the original
 153    * {@link Qedeq} instance.
 154    * <p>
 155    * During the creation process the caller must assert that no modifications are made
 156    * to the {@link Qedeq} instance including its referenced objects.
 157    *
 158    * @param original Basic QEDEQ module object.
 159    * @return Filled header business object. Is equal to the parameter <code>header</code>.
 160    * @throws IllegalModuleDataException Basic semantic error occurred.
 161    */
 162  32 protected final QedeqBo create(final Qedeq original) throws IllegalModuleDataException {
 163  32 this.original = original;
 164  32 getCurrentContext().setLocationWithinModule("");
 165  32 if (original == null) {
 166  0 qedeq = null;
 167  0 return qedeq;
 168    }
 169  32 qedeq = new QedeqBo();
 170  32 final String context = getCurrentContext().getLocationWithinModule();
 171  32 if (original.getHeader() != null) {
 172  32 getCurrentContext().setLocationWithinModule(context + "getHeader()");
 173  32 qedeq.setHeader(create(original.getHeader()));
 174    }
 175  32 if (original.getChapterList() != null) {
 176  32 getCurrentContext().setLocationWithinModule(context + "getChapterList()");
 177  32 qedeq.setChapterList(create(original.getChapterList()));
 178    }
 179  30 if (original.getLiteratureItemList() != null) {
 180  9 getCurrentContext().setLocationWithinModule(context + "getLiteratureItemList()");
 181  9 qedeq.setLiteratureItemList(create(original.getLiteratureItemList()));
 182    }
 183  30 return qedeq;
 184    }
 185   
 186    /**
 187    * Create {@link HeaderVo} out of an {@link Header} instance.
 188    * During that procedure some basic checking is done. E.g. the uniqueness of entries
 189    * is tested. The resulting business object has no references to the original
 190    * {@link Header} instance.
 191    * <p>
 192    * During the creation process the caller must assert that no modifications are made
 193    * to the {@link Header} instance including its referenced objects.
 194    *
 195    * @param header Basic header object.
 196    * @return Filled header business object. Is equal to the parameter <code>header</code>.
 197    * @throws IllegalModuleDataException Basic semantic error occurred.
 198    */
 199  32 private final HeaderVo create(final Header header)
 200    throws IllegalModuleDataException {
 201  32 if (header == null) {
 202  0 return null;
 203    }
 204  32 final HeaderVo h = new HeaderVo();
 205  32 final String context = getCurrentContext().getLocationWithinModule();
 206  32 if (header.getTitle() != null) {
 207  32 setLocationWithinModule(context + ".getTitle()");
 208  32 h.setTitle(create(header.getTitle()));
 209    }
 210  32 if (header.getAuthorList() != null) {
 211  32 setLocationWithinModule(context + ".getAuthorList()");
 212  32 h.setAuthorList(create(header.getAuthorList()));
 213    }
 214  32 if (header.getSummary() != null) {
 215  32 setLocationWithinModule(context + ".getSummary()");
 216  32 h.setSummary(create(header.getSummary()));
 217    }
 218  32 if (header.getEmail() != null) {
 219  32 setLocationWithinModule(context + ".getEmail()");
 220  32 h.setEmail(header.getEmail());
 221    }
 222  32 if (header.getSpecification() != null) {
 223  32 setLocationWithinModule(context + ".getSpecification()");
 224  32 h.setSpecification(create(header.getSpecification()));
 225    }
 226  32 if (header.getImportList() != null) {
 227  16 setLocationWithinModule(context + ".getImportList()");
 228  16 h.setImportList(create(header.getImportList()));
 229    }
 230  32 if (header.getUsedByList() != null) {
 231  15 setLocationWithinModule(context + ".getUsedByList()");
 232  15 h.setUsedByList(create(header.getUsedByList()));
 233    }
 234  32 setLocationWithinModule(context);
 235  32 return h;
 236    }
 237   
 238    /**
 239    * Create {@link UsedByListVo} out of an {@link UsedByList} instance.
 240    * During that procedure some basic checking is done. E.g. the uniqueness of entries
 241    * is tested. The resulting business object has no references to the original
 242    * {@link UsedByList} instance.
 243    * <p>
 244    * During the creation process the caller must assert that no modifications are made
 245    * to the {@link UsedByList} instance including its referenced objects.
 246    *
 247    * @param usedByList Basic header object.
 248    * @return Filled used by business object. Is equal to the parameter <code>usedByList</code>.
 249    */
 250  15 private final UsedByListVo create(final UsedByList usedByList) {
 251  15 if (usedByList == null) {
 252  0 return null;
 253    }
 254  15 final String context = getCurrentContext().getLocationWithinModule();
 255  15 final UsedByListVo list = new UsedByListVo();
 256  15 for (int i = 0; i < usedByList.size(); i++) {
 257  15 setLocationWithinModule(context + ".get(" + i + ")");
 258  15 list.add(create(usedByList.get(i)));
 259    }
 260  15 setLocationWithinModule(context);
 261  15 return list;
 262    }
 263   
 264  16 private final ImportListVo create(final ImportList importList) {
 265  16 if (importList == null) {
 266  0 return null;
 267    }
 268  16 final String context = getCurrentContext().getLocationWithinModule();
 269  16 final ImportListVo list = new ImportListVo();
 270  16 for (int i = 0; i < importList.size(); i++) {
 271  27 setLocationWithinModule(context + ".get(" + i + ")");
 272  27 list.add(create(importList.get(i)));
 273    }
 274  16 setLocationWithinModule(context);
 275  16 return list;
 276    }
 277   
 278  27 private final ImportVo create(final Import imp) {
 279  27 if (imp == null) {
 280  0 return null;
 281    }
 282  27 final ImportVo i = new ImportVo();
 283  27 final String context = getCurrentContext().getLocationWithinModule();
 284  27 if (imp.getLabel() != null) {
 285  27 setLocationWithinModule(context + ".getLabel()");
 286  27 i.setLabel(imp.getLabel());
 287    }
 288  27 if (imp.getSpecification() != null) {
 289  27 setLocationWithinModule(context + ".getSpecification()");
 290  27 i.setSpecification(create(imp.getSpecification()));
 291    }
 292  27 setLocationWithinModule(context);
 293  27 return i;
 294    }
 295   
 296  74 private final SpecificationVo create(final Specification specification) {
 297  74 if (specification == null) {
 298  0 return null;
 299    }
 300  74 final SpecificationVo s = new SpecificationVo();
 301  74 final String context = getCurrentContext().getLocationWithinModule();
 302  74 if (specification.getName() != null) {
 303  74 setLocationWithinModule(context + ".getName()");
 304  74 s.setName(specification.getName());
 305    }
 306  74 if (specification.getRuleVersion() != null) {
 307  74 setLocationWithinModule(context + ".getRuleVersion()");
 308  74 s.setRuleVersion(specification.getRuleVersion());
 309    }
 310  74 if (specification.getLocationList() != null) {
 311  74 setLocationWithinModule(context + ".getLocationList()");
 312  74 s.setLocationList(create(specification.getLocationList()));
 313    }
 314  74 setLocationWithinModule(context);
 315  74 return s;
 316    }
 317   
 318  74 private final LocationListVo create(final LocationList locationList) {
 319  74 if (locationList == null) {
 320  0 return null;
 321    }
 322  74 final LocationListVo list = new LocationListVo();
 323  74 final String context = getCurrentContext().getLocationWithinModule();
 324  74 for (int i = 0; i < locationList.size(); i++) {
 325  74 setLocationWithinModule(context + ".get(" + i + ")");
 326  74 list.add(create(locationList.get(i)));
 327    }
 328  74 setLocationWithinModule(context);
 329  74 return list;
 330    }
 331   
 332  74 private final LocationVo create(final Location location) {
 333  74 if (location == null) {
 334  0 return null;
 335    }
 336  74 final LocationVo loc = new LocationVo();
 337  74 final String context = getCurrentContext().getLocationWithinModule();
 338  74 if (location.getLocation() != null) {
 339  74 setLocationWithinModule(context + ".getLocation()");
 340  74 loc.setLocation(location.getLocation());
 341    }
 342  74 setLocationWithinModule(context);
 343  74 return loc;
 344    }
 345   
 346  32 private final AuthorListVo create(final AuthorList authorList) {
 347  32 if (authorList == null) {
 348  0 return null;
 349    }
 350  32 final AuthorListVo list = new AuthorListVo();
 351  32 final String context = getCurrentContext().getLocationWithinModule();
 352  32 for (int i = 0; i < authorList.size(); i++) {
 353  32 setLocationWithinModule(context + ".get(" + i + ")");
 354  32 list.add(create(authorList.get(i)));
 355    }
 356  32 setLocationWithinModule(context);
 357  32 return list;
 358    }
 359   
 360  32 private final AuthorVo create(final Author author) {
 361  32 if (author == null) {
 362  0 return null;
 363    }
 364  32 final AuthorVo a = new AuthorVo();
 365  32 final String context = getCurrentContext().getLocationWithinModule();
 366  32 if (author.getName() != null) {
 367  32 setLocationWithinModule(context + ".getName()");
 368  32 a.setName(create(author.getName()));
 369    }
 370  32 if (author.getEmail() != null) {
 371  32 setLocationWithinModule(context + ".getEmail()");
 372  32 a.setEmail(author.getEmail());
 373    }
 374  32 setLocationWithinModule(context);
 375  32 return a;
 376    }
 377   
 378  32 private final ChapterListVo create(final ChapterList chapterList)
 379    throws IllegalModuleDataException {
 380  32 if (chapterList == null) {
 381  0 return null;
 382    }
 383  32 final ChapterListVo list = new ChapterListVo();
 384  32 final String context = getCurrentContext().getLocationWithinModule();
 385  32 for (int i = 0; i < chapterList.size(); i++) {
 386  133 setLocationWithinModule(context + ".get(" + i + ")");
 387  133 list.add(create(chapterList.get(i)));
 388    }
 389  30 setLocationWithinModule(context);
 390  30 return list;
 391    }
 392   
 393  133 private final ChapterVo create(final Chapter chapter)
 394    throws IllegalModuleDataException {
 395  133 if (chapter == null) {
 396  0 return null;
 397    }
 398  133 final ChapterVo c = new ChapterVo();
 399  133 final String context = getCurrentContext().getLocationWithinModule();
 400  133 if (chapter.getTitle() != null) {
 401  133 setLocationWithinModule(context + ".getTitle()");
 402  133 c.setTitle(create(chapter.getTitle()));
 403    }
 404  133 if (chapter.getNoNumber() != null) {
 405  42 setLocationWithinModule(context + ".getNoNumber()");
 406  42 c.setNoNumber(chapter.getNoNumber());
 407    }
 408  133 if (chapter.getIntroduction() != null) {
 409  130 setLocationWithinModule(context + ".getIntroduction()");
 410  130 c.setIntroduction(create(chapter.getIntroduction()));
 411    }
 412  133 if (chapter.getSectionList() != null) {
 413  82 setLocationWithinModule(context + ".getSectionList()");
 414  82 c.setSectionList(create(chapter.getSectionList()));
 415    }
 416  131 setLocationWithinModule(context);
 417  131 return c;
 418    }
 419   
 420  9 private LiteratureItemListVo create(final LiteratureItemList literatureItemList)
 421    throws IllegalModuleDataException {
 422  9 if (literatureItemList == null) {
 423  0 return null;
 424    }
 425  9 final LiteratureItemListVo list = new LiteratureItemListVo();
 426  9 final String context = getCurrentContext().getLocationWithinModule();
 427  9 for (int i = 0; i < literatureItemList.size(); i++) {
 428  43 setLocationWithinModule(context + ".get(" + i + ")");
 429  43 list.add(create(literatureItemList.get(i)));
 430    }
 431  9 setLocationWithinModule(context);
 432  9 return list;
 433    }
 434   
 435  43 private LiteratureItemVo create(final LiteratureItem item)
 436    throws IllegalModuleDataException {
 437  43 if (item == null) {
 438  0 return null;
 439    }
 440  43 final LiteratureItemVo it = new LiteratureItemVo();
 441  43 final String context = getCurrentContext().getLocationWithinModule();
 442  43 if (item.getLabel() != null) {
 443  43 setLocationWithinModule(context + ".getLabel()");
 444  43 it.setLabel(item.getLabel());
 445    }
 446  43 if (item.getItem() != null) {
 447  43 setLocationWithinModule(context + ".getItem()");
 448  43 it.setItem(create(item.getItem()));
 449    }
 450  43 setLocationWithinModule(context);
 451  43 return it;
 452   
 453    }
 454   
 455  82 private final SectionListVo create(final SectionList sectionList)
 456    throws IllegalModuleDataException {
 457  82 if (sectionList == null) {
 458  0 return null;
 459    }
 460  82 final SectionListVo list = new SectionListVo();
 461  82 final String context = getCurrentContext().getLocationWithinModule();
 462  82 for (int i = 0; i < sectionList.size(); i++) {
 463  228 setLocationWithinModule(context + ".get(" + i + ")");
 464  228 list.add(create(sectionList.get(i)));
 465    }
 466  80 setLocationWithinModule(context);
 467  80 return list;
 468    }
 469   
 470  228 private final SectionVo create(final Section section)
 471    throws IllegalModuleDataException {
 472  228 if (section == null) {
 473  0 return null;
 474    }
 475  228 final SectionVo s = new SectionVo();
 476  228 final String context = getCurrentContext().getLocationWithinModule();
 477  228 if (section.getTitle() != null) {
 478  228 setLocationWithinModule(context + ".getTitle()");
 479  228 s.setTitle(create(section.getTitle()));
 480    }
 481  228 if (section.getNoNumber() != null) {
 482  0 setLocationWithinModule(context + ".getNoNumber()");
 483  0 s.setNoNumber(section.getNoNumber());
 484    }
 485  228 if (section.getIntroduction() != null) {
 486  225 setLocationWithinModule(context + ".getIntroduction()");
 487  225 s.setIntroduction(create(section.getIntroduction()));
 488    }
 489  228 if (section.getSubsectionList() != null) {
 490  106 setLocationWithinModule(context + ".getSubsectionList()");
 491  106 s.setSubsectionList(create(section.getSubsectionList()));
 492    }
 493  226 setLocationWithinModule(context);
 494  226 return s;
 495    }
 496   
 497  106 private final SubsectionListVo create(final SubsectionList subsectionList)
 498    throws IllegalModuleDataException {
 499  106 if (subsectionList == null) {
 500  0 return null;
 501    }
 502  106 final SubsectionListVo list = new SubsectionListVo();
 503  106 final String context = getCurrentContext().getLocationWithinModule();
 504  106 for (int i = 0; i < subsectionList.size(); i++) {
 505  652 setLocationWithinModule(context + ".get(" + i + ")");
 506    // TODO mime 20050608: here the Subsection context is type dependently specified
 507  652 if (subsectionList.get(i) instanceof Subsection) {
 508  103 list.add(create((Subsection) subsectionList.get(i)));
 509  549 } else if (subsectionList.get(i) instanceof Node) {
 510  549 list.add(create((Node) subsectionList.get(i)));
 511    } else {
 512  0 throw new IllegalArgumentException("unexpected subsection type: "
 513    + subsectionList.get(i).getClass());
 514    }
 515    }
 516  104 setLocationWithinModule(context);
 517  104 return list;
 518    }
 519   
 520  103 private final SubsectionVo create(final Subsection subsection) {
 521  103 if (subsection == null) {
 522  0 return null;
 523    }
 524  103 final SubsectionVo s = new SubsectionVo();
 525  103 final String context = getCurrentContext().getLocationWithinModule();
 526  103 if (subsection.getTitle() != null) {
 527  90 setLocationWithinModule(context + ".getTitle()");
 528  90 s.setTitle(create(subsection.getTitle()));
 529    }
 530  103 if (subsection.getLevel() != null) {
 531  0 setLocationWithinModule(context + ".getLevel()");
 532  0 s.setLevel(subsection.getLevel());
 533    }
 534  103 if (subsection.getLatex() != null) {
 535  103 setLocationWithinModule(context + ".getLatex()");
 536  103 s.setLatex(create(subsection.getLatex()));
 537    }
 538  103 setLocationWithinModule(context);
 539  103 return s;
 540    }
 541   
 542  549 private final NodeVo create(final Node node)
 543    throws IllegalModuleDataException {
 544  549 if (node == null) {
 545  0 return null;
 546    }
 547  549 final NodeVo n = new NodeVo();
 548  549 final String context = getCurrentContext().getLocationWithinModule();
 549  549 if (node.getName() != null) {
 550  275 setLocationWithinModule(context + ".getName()");
 551  275 n.setName(create(node.getName()));
 552    }
 553  549 if (node.getId() != null) {
 554  549 setLocationWithinModule(context + ".getId()");
 555  549 n.setId(node.getId());
 556    }
 557  549 if (node.getLevel() != null) {
 558  364 setLocationWithinModule(context + ".getLevel()");
 559  364 n.setLevel(node.getLevel());
 560    }
 561  549 if (node.getTitle() != null) {
 562  275 setLocationWithinModule(context + ".getTitle()");
 563  275 n.setTitle(create(node.getTitle()));
 564    }
 565  549 if (node.getPrecedingText() != null) {
 566  522 setLocationWithinModule(context + ".getPrecedingText()");
 567  522 n.setPrecedingText(create(node.getPrecedingText()));
 568    }
 569  549 if (node.getNodeType() != null) {
 570  549 setLocationWithinModule(context + ".getNodeType()");
 571  549 if (node.getNodeType() instanceof Axiom) {
 572  93 setLocationWithinModule(context + ".getNodeType().getAxiom()");
 573  93 n.setNodeType(create((Axiom) node.getNodeType()));
 574  456 } else if (node.getNodeType() instanceof PredicateDefinition) {
 575  69 setLocationWithinModule(context + ".getNodeType().getPredicateDefinition()");
 576  69 n.setNodeType(create((PredicateDefinition) node.getNodeType()));
 577  387 } else if (node.getNodeType() instanceof FunctionDefinition) {
 578  80 setLocationWithinModule(context + ".getNodeType().getFunctionDefinition()");
 579  80 n.setNodeType(create((FunctionDefinition) node.getNodeType()));
 580  307 } else if (node.getNodeType() instanceof Proposition) {
 581  274 setLocationWithinModule(context + ".getNodeType().getProposition()");
 582  274 n.setNodeType(create((Proposition) node.getNodeType()));
 583  33 } else if (node.getNodeType() instanceof Rule) {
 584  33 setLocationWithinModule(context + ".getNodeType().getRule()");
 585  33 n.setNodeType(create((Rule) node.getNodeType()));
 586    } else {
 587  0 throw new IllegalArgumentException("unexpected node type: "
 588    + node.getNodeType().getClass());
 589    }
 590    }
 591  549 if (node.getSucceedingText() != null) {
 592  121 setLocationWithinModule(context + ".getSucceedingText()");
 593  121 n.setSucceedingText(create(node.getSucceedingText()));
 594    }
 595  549 setLocationWithinModule(context);
 596  549 getQedeqCreated().getModuleLabels().addNode(getCurrentContext(), n);
 597  547 return n;
 598    }
 599   
 600  93 private final AxiomVo create(final Axiom axiom) {
 601  93 if (axiom == null) {
 602  0 return null;
 603    }
 604  93 final AxiomVo a = new AxiomVo();
 605  93 final String context = getCurrentContext().getLocationWithinModule();
 606  93 if (axiom.getFormula() != null) {
 607  93 setLocationWithinModule(context + ".getFormula()");
 608  93 a.setFormula(create(axiom.getFormula()));
 609    }
 610  93 if (axiom.getDescription() != null) {
 611  0 setLocationWithinModule(context + ".getDescription()");
 612  0 a.setDescription(create(axiom.getDescription()));
 613    }
 614  93 setLocationWithinModule(context);
 615  93 return a;
 616    }
 617   
 618  69 private final PredicateDefinitionVo create(final PredicateDefinition definition) {
 619  69 if (definition == null) {
 620  0 return null;
 621    }
 622  69 final PredicateDefinitionVo d = new PredicateDefinitionVo();
 623  69 final String context = getCurrentContext().getLocationWithinModule();
 624  69 if (definition.getLatexPattern() != null) {
 625  69 setLocationWithinModule(context + ".getLatexPattern()");
 626  69 d.setLatexPattern(definition.getLatexPattern());
 627    }
 628  69 if (definition.getName() != null) {
 629  69 setLocationWithinModule(context + ".getName()");
 630  69 d.setName(definition.getName());
 631    }
 632  69 if (definition.getArgumentNumber() != null) {
 633  69 setLocationWithinModule(context + ".getArgumentNumber()");
 634  69 d.setArgumentNumber(definition.getArgumentNumber());
 635    }
 636  69 if (definition.getVariableList() != null) {
 637  69 setLocationWithinModule(context + ".getVariableList()");
 638  69 d.setVariableList(create(definition.getVariableList()));
 639    }
 640  69 if (definition.getFormula() != null) {
 641  53 setLocationWithinModule(context + ".getFormula()");
 642  53 d.setFormula(create(definition.getFormula()));
 643    }
 644  69 if (definition.getDescription() != null) {
 645  0 setLocationWithinModule(context + ".getDescription()");
 646  0 d.setDescription(create(definition.getDescription()));
 647    }
 648  69 setLocationWithinModule(context);
 649  69 return d;
 650    }
 651   
 652  80 private final FunctionDefinitionVo create(final FunctionDefinition definition) {
 653  80 if (definition == null) {
 654  0 return null;
 655    }
 656  80 final FunctionDefinitionVo d = new FunctionDefinitionVo();
 657  80 final String context = getCurrentContext().getLocationWithinModule();
 658  80 if (definition.getLatexPattern() != null) {
 659  80 setLocationWithinModule(context + ".getLatexPattern()");
 660  80 d.setLatexPattern(definition.getLatexPattern());
 661    }
 662  80 if (definition.getArgumentNumber() != null) {
 663  80 setLocationWithinModule(context + ".getArgumentNumber()");
 664  80 d.setArgumentNumber(definition.getArgumentNumber());
 665    }
 666  80 if (definition.getName() != null) {
 667  80 setLocationWithinModule(context + ".getName()");
 668  80 d.setName(definition.getName());
 669    }
 670  80 if (definition.getVariableList() != null) {
 671  65 setLocationWithinModule(context + ".getVariableList()");
 672  65 d.setVariableList(create(definition.getVariableList()));
 673    }
 674  80 if (definition.getTerm() != null) {
 675  80 setLocationWithinModule(context + ".getTerm()");
 676  80 d.setTerm(create(definition.getTerm()));
 677    }
 678  80 if (definition.getDescription() != null) {
 679  0 setLocationWithinModule(context + ".getDescription()");
 680  0 d.setDescription(create(definition.getDescription()));
 681    }
 682  80 setLocationWithinModule(context);
 683  80 return d;
 684    }
 685   
 686  274 private final PropositionVo create(final Proposition proposition) {
 687  274 if (proposition == null) {
 688  0 return null;
 689    }
 690  274 final PropositionVo p = new PropositionVo();
 691  274 final String context = getCurrentContext().getLocationWithinModule();
 692  274 if (proposition.getFormula() != null) {
 693  274 setLocationWithinModule(context + ".getFormula()");
 694  274 p.setFormula(create(proposition.getFormula()));
 695    }
 696  274 if (proposition.getDescription() != null) {
 697  5 setLocationWithinModule(context + ".getDescription()");
 698  5 p.setDescription(create(proposition.getDescription()));
 699    }
 700  274 if (proposition.getProofList() != null) {
 701  29 setLocationWithinModule(context + ".getProofList()");
 702  29 p.setProofList(create(proposition.getProofList()));
 703    }
 704  274 setLocationWithinModule(context);
 705  274 return p;
 706    }
 707   
 708  33 private final RuleVo create(final Rule rule) {
 709  33 if (rule == null) {
 710  0 return null;
 711    }
 712  33 final RuleVo r = new RuleVo();
 713  33 final String context = getCurrentContext().getLocationWithinModule();
 714  33 if (rule.getName() != null) {
 715  33 setLocationWithinModule(context + ".getName()");
 716  33 r.setName(rule.getName());
 717    }
 718  33 if (rule.getLinkList() != null) {
 719  5 setLocationWithinModule(context + ".getLinkList()");
 720  5 r.setLinkList(create(rule.getLinkList()));
 721    }
 722  33 if (rule.getDescription() != null) {
 723  33 setLocationWithinModule(context + ".getDescription()");
 724  33 r.setDescription(create(rule.getDescription()));
 725    }
 726  33 if (rule.getProofList() != null) {
 727  0 setLocationWithinModule(context + ".getProofList()");
 728  0 r.setProofList(create(rule.getProofList()));
 729    }
 730  33 setLocationWithinModule(context);
 731  33 return r;
 732    }
 733   
 734  5 private final LinkListVo create(final LinkList linkList) {
 735  5 if (linkList == null) {
 736  0 return null;
 737    }
 738  5 final LinkListVo list = new LinkListVo();
 739  5 final String context = getCurrentContext().getLocationWithinModule();
 740  5 for (int i = 0; i < linkList.size(); i++) {
 741  5 setLocationWithinModule(context + ".get(" + i + ")");
 742  5 list.add(linkList.get(i));
 743    }
 744  5 setLocationWithinModule(context);
 745  5 return list;
 746    }
 747   
 748  134 private final VariableListVo create(final VariableList variableList) {
 749  134 if (variableList == null) {
 750  0 return null;
 751    }
 752  134 final VariableListVo list = new VariableListVo();
 753  134 final String context = getCurrentContext().getLocationWithinModule();
 754  134 for (int i = 0; i < variableList.size(); i++) {
 755  197 setLocationWithinModule(context + ".get(" + i + ")");
 756  197 list.add(create(variableList.get(i)));
 757    }
 758  134 setLocationWithinModule(context);
 759  134 return list;
 760    }
 761   
 762  29 private final ProofListVo create(final ProofList proofList) {
 763  29 if (proofList == null) {
 764  0 return null;
 765    }
 766  29 final ProofListVo list = new ProofListVo();
 767  29 final String context = getCurrentContext().getLocationWithinModule();
 768  29 for (int i = 0; i < proofList.size(); i++) {
 769  29 setLocationWithinModule(context + ".get(" + i + ")");
 770  29 list.add(create(proofList.get(i)));
 771    }
 772  29 setLocationWithinModule(context);
 773  29 return list;
 774    }
 775   
 776  29 private final ProofVo create(final Proof proof) {
 777  29 if (proof == null) {
 778  0 return null;
 779    }
 780  29 final ProofVo p = new ProofVo();
 781  29 final String context = getCurrentContext().getLocationWithinModule();
 782  29 setLocationWithinModule(context + ".getKind()");
 783  29 p.setKind(proof.getKind());
 784  29 setLocationWithinModule(context + ".getLevel()");
 785  29 p.setLevel(proof.getLevel());
 786  29 setLocationWithinModule(context);
 787  29 if (proof.getNonFormalProof() != null) {
 788  29 setLocationWithinModule(context + ".getNonFormalProof()");
 789  29 p.setNonFormalProof(create(proof.getNonFormalProof()));
 790    }
 791  29 setLocationWithinModule(context);
 792  29 return p;
 793    }
 794   
 795  420 private final FormulaVo create(final Formula formula) {
 796  420 if (formula == null) {
 797  0 return null;
 798    }
 799  420 final FormulaVo f = new FormulaVo();
 800  420 final String context = getCurrentContext().getLocationWithinModule();
 801  420 if (formula.getElement() != null) {
 802  420 setLocationWithinModule(context + ".getElement()");
 803  420 f.setElement(create(formula.getElement()));
 804    }
 805  420 setLocationWithinModule(context);
 806  420 return f;
 807    }
 808   
 809  80 private final TermVo create(final Term term) {
 810  80 if (term == null) {
 811  0 return null;
 812    }
 813  80 final TermVo f = new TermVo();
 814  80 final String context = getCurrentContext().getLocationWithinModule();
 815  80 if (term.getElement() != null) {
 816  80 setLocationWithinModule(context + ".getElement()");
 817  80 f.setElement(create(term.getElement()));
 818    }
 819  80 setLocationWithinModule(context);
 820  80 return f;
 821    }
 822   
 823  14428 private final Element create(final Element element) {
 824  14428 if (element == null) {
 825  0 return null;
 826    }
 827  14428 final Element e;
 828  14428 final String context = getCurrentContext().getLocationWithinModule();
 829  14428 if (element.isList()) {
 830  7914 setLocationWithinModule(context + ".getList()");
 831  7914 e = create(element.getList());
 832  6514 } else if (element.isAtom()) {
 833    // setLocationWithinModule(context + ".getAtom()");
 834  6514 return create(element.getAtom());
 835    } else {
 836  0 throw new RuntimeException("unknown element type: " + element);
 837    }
 838  7914 setLocationWithinModule(context);
 839  7914 return e;
 840    }
 841   
 842   
 843  7914 private final ElementListImpl create(final ElementList list) {
 844  7914 if (list == null) {
 845  0 return null;
 846    }
 847  7914 final ElementListImpl n = new ElementListImpl(list.getOperator(), new Element[] {});
 848  7914 final String context = getCurrentContext().getLocationWithinModule();
 849  7914 for (int i = 0; i < list.size(); i++) {
 850  13731 if (list.getElement(i).isList()) {
 851  7217 setLocationWithinModule(context + ".getElement(" + i + ")");
 852    }
 853  13731 n.add(create(list.getElement(i)));
 854    }
 855  7914 setLocationWithinModule(context);
 856  7914 return n;
 857    }
 858   
 859  6514 private final AtomImpl create(final Atom atom) {
 860  6514 if (atom == null) {
 861  0 return null;
 862    }
 863  6514 final String context = getCurrentContext().getLocationWithinModule();
 864  6514 return new AtomImpl(atom.getString());
 865    }
 866   
 867  2276 private final LatexListVo create(final LatexList latexList) {
 868  2276 if (latexList == null) {
 869  0 return null;
 870    }
 871  2276 final LatexListVo list = new LatexListVo();
 872  2276 final String context = getCurrentContext().getLocationWithinModule();
 873  2276 for (int i = 0; i < latexList.size(); i++) {
 874  4014 setLocationWithinModule(context + ".get(" + i + ")");
 875  4014 list.add(create(latexList.get(i)));
 876    }
 877  2276 setLocationWithinModule(context);
 878  2276 return list;
 879    }
 880   
 881    /**
 882    * Creates LaTeX business object.
 883    *
 884    * @param latex LaTeX object.
 885    * @return LaTeX business object.
 886    */
 887  4046 private final LatexVo create(final Latex latex) {
 888  4046 if (latex == null) {
 889  0 return null;
 890    }
 891  4046 final LatexVo lat = new LatexVo();
 892    // TODO mime 20050707: use here creation process also?
 893  4046 lat.setLanguage(latex.getLanguage());
 894  4046 lat.setLatex(latex.getLatex());
 895  4046 return lat;
 896    }
 897   
 898    /**
 899    * Set location information where are we within the orginal module.
 900    *
 901    * @param locationWithinModule Location within module.
 902    */
 903  29226 protected void setLocationWithinModule(final String locationWithinModule) {
 904  29226 getCurrentContext().setLocationWithinModule(locationWithinModule);
 905    }
 906   
 907    /**
 908    * Get current context within original.
 909    *
 910    * @return Current context.
 911    */
 912  159906 protected final ModuleContext getCurrentContext() {
 913  159906 return currentContext;
 914    }
 915   
 916    /**
 917    * Get original qedeq module.
 918    *
 919    * @return Original qedeq module.
 920    */
 921  38382 protected final Qedeq getQedeqOriginal() {
 922  38382 return original;
 923    }
 924   
 925    /**
 926    * Get currently created qedeq module.
 927    *
 928    * @return Currently created qedeq module.
 929    */
 930  549 protected final QedeqBo getQedeqCreated() {
 931  549 return qedeq;
 932    }
 933   
 934    }