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 java.io.IOException; |
21 |
|
import java.lang.reflect.InvocationTargetException; |
22 |
|
|
23 |
|
import javax.xml.parsers.ParserConfigurationException; |
24 |
|
|
25 |
|
import org.qedeq.base.io.IoUtility; |
26 |
|
import org.qedeq.base.test.DynamicGetter; |
27 |
|
import org.qedeq.base.trace.Trace; |
28 |
|
import org.qedeq.kernel.base.module.Qedeq; |
29 |
|
import org.qedeq.kernel.bo.module.InternalKernelServices; |
30 |
|
import org.qedeq.kernel.bo.module.QedeqFileDao; |
31 |
|
import org.qedeq.kernel.bo.service.DefaultKernelQedeqBo; |
32 |
|
import org.qedeq.kernel.bo.service.ModuleLabelsCreator; |
33 |
|
import org.qedeq.kernel.bo.service.QedeqVoBuilder; |
34 |
|
import org.qedeq.kernel.bo.service.latex.QedeqBoDuplicateLanguageChecker; |
35 |
|
import org.qedeq.kernel.bo.test.KernelFacade; |
36 |
|
import org.qedeq.kernel.common.LoadingState; |
37 |
|
import org.qedeq.kernel.common.ModuleAddress; |
38 |
|
import org.qedeq.kernel.common.ModuleDataException; |
39 |
|
import org.qedeq.kernel.common.SourceFileExceptionList; |
40 |
|
import org.qedeq.kernel.dto.module.QedeqVo; |
41 |
|
import org.qedeq.kernel.xml.dao.XmlQedeqFileDao; |
42 |
|
import org.qedeq.kernel.xml.mapper.Context2SimpleXPath; |
43 |
|
import org.qedeq.kernel.xml.tracker.SimpleXPath; |
44 |
|
import org.qedeq.kernel.xml.tracker.XPathLocationParser; |
45 |
|
import org.xml.sax.SAXException; |
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
|
50 |
|
@version |
51 |
|
@author |
52 |
|
|
|
|
| 64,2% |
Uncovered Elements: 19 (53) |
Complexity: 14 |
Complexity Density: 0,32 |
|
53 |
|
public class QedeqBoFactoryAssert extends QedeqVoBuilder { |
54 |
|
|
55 |
|
|
56 |
|
private static final Class CLASS = QedeqBoFactoryAssert.class; |
57 |
|
|
58 |
|
|
59 |
|
|
60 |
|
|
61 |
|
@param |
62 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
63 |
11
|
public QedeqBoFactoryAssert(final ModuleAddress address) {... |
64 |
11
|
super(address); |
65 |
|
} |
66 |
|
|
67 |
|
|
68 |
|
@link@link |
69 |
|
|
70 |
|
|
71 |
|
|
72 |
|
@link |
73 |
|
|
74 |
|
|
75 |
|
@link |
76 |
|
|
77 |
|
@param |
78 |
|
@param |
79 |
|
@throws |
80 |
|
|
|
|
| 75% |
Uncovered Elements: 5 (20) |
Complexity: 3 |
Complexity Density: 0,17 |
|
81 |
11
|
public static void createQedeq(final DefaultKernelQedeqBo prop,... |
82 |
|
final Qedeq original) throws SourceFileExceptionList { |
83 |
11
|
final QedeqBoFactoryAssert creator = new QedeqBoFactoryAssert(prop.getModuleAddress()); |
84 |
11
|
final QedeqVo vo; |
85 |
11
|
try { |
86 |
11
|
vo = creator.create(original); |
87 |
|
} catch (ModuleDataException e) { |
88 |
0
|
final SourceFileExceptionList xl |
89 |
|
= prop.createSourceFileExceptionList(e, original); |
90 |
0
|
prop.setLoadingFailureState(LoadingState.STATE_LOADING_INTO_MEMORY_FAILED, xl); |
91 |
0
|
throw xl; |
92 |
|
} |
93 |
11
|
final InternalKernelServices services = (InternalKernelServices) IoUtility |
94 |
|
.getFieldContent(KernelFacade.getKernelContext(), "services"); |
95 |
11
|
final QedeqFileDao loader = new XmlQedeqFileDao(); |
96 |
11
|
loader.setServices(services); |
97 |
11
|
prop.setQedeqFileDao(loader); |
98 |
11
|
prop.setQedeqVo(vo); |
99 |
11
|
prop.setLoaded(vo, new ModuleLabelsCreator(prop).createLabels()); |
100 |
10
|
KernelFacade.getKernelContext().loadRequiredModules(prop.getModuleAddress()); |
101 |
10
|
KernelFacade.getKernelContext().checkModule(prop.getModuleAddress()); |
102 |
10
|
if (!prop.isChecked()) { |
103 |
0
|
throw prop.getException(); |
104 |
|
} |
105 |
10
|
QedeqBoDuplicateLanguageChecker.check(prop); |
106 |
|
} |
107 |
|
|
108 |
|
|
109 |
|
|
110 |
|
|
111 |
|
@param |
112 |
|
|
|
|
| 51,7% |
Uncovered Elements: 14 (29) |
Complexity: 10 |
Complexity Density: 0,4 |
|
113 |
24824
|
protected void setLocationWithinModule(final String locationWithinModule) {... |
114 |
24824
|
Trace.param(CLASS, "setLocationWithinModule(String)", |
115 |
|
"locationWithinModule > ", locationWithinModule); |
116 |
24824
|
getCurrentContext().setLocationWithinModule(locationWithinModule); |
117 |
|
|
118 |
24824
|
try { |
119 |
24824
|
DynamicGetter.get(getQedeqOriginal(), getCurrentContext().getLocationWithinModule()); |
120 |
|
} catch (RuntimeException e) { |
121 |
0
|
System.err.println(getCurrentContext().getLocationWithinModule()); |
122 |
0
|
throw e; |
123 |
|
} catch (IllegalAccessException e) { |
124 |
0
|
throw new RuntimeException(e); |
125 |
|
} catch (InvocationTargetException e) { |
126 |
0
|
throw new RuntimeException(e); |
127 |
|
} |
128 |
|
|
129 |
24824
|
SimpleXPath xpath; |
130 |
24824
|
try { |
131 |
24824
|
xpath = Context2SimpleXPath.getXPath(getCurrentContext(), getQedeqOriginal()); |
132 |
|
} catch (ModuleDataException e) { |
133 |
0
|
throw new RuntimeException(e); |
134 |
|
} |
135 |
24824
|
Trace.param(CLASS, "setLocationWithinModule(String)", |
136 |
|
"xpath < ", xpath); |
137 |
24824
|
try { |
138 |
24824
|
final InternalKernelServices services = (InternalKernelServices) IoUtility |
139 |
|
.getFieldContent(KernelFacade.getKernelContext(), "services"); |
140 |
24824
|
final SimpleXPath find = XPathLocationParser.getXPathLocation( |
141 |
|
services.getLocalFilePath( |
142 |
|
getCurrentContext().getModuleLocation()), xpath, |
143 |
|
getCurrentContext().getModuleLocation().getURL()); |
144 |
24824
|
if (find.getStartLocation() == null) { |
145 |
0
|
System.out.println(getCurrentContext()); |
146 |
0
|
throw new RuntimeException("start not found: " + find + "\ncontext: " |
147 |
|
+ getCurrentContext().getLocationWithinModule()); |
148 |
|
} |
149 |
24824
|
if (find.getEndLocation() == null) { |
150 |
0
|
System.out.println(getCurrentContext()); |
151 |
0
|
throw new RuntimeException("end not found: " + find + "\ncontext: " |
152 |
|
+ getCurrentContext().getLocationWithinModule()); |
153 |
|
} |
154 |
|
|
155 |
|
} catch (ParserConfigurationException e) { |
156 |
0
|
throw new RuntimeException(e); |
157 |
|
} catch (SAXException e) { |
158 |
0
|
throw new RuntimeException(e); |
159 |
|
} catch (IOException e) { |
160 |
0
|
throw new RuntimeException(e); |
161 |
|
} |
162 |
|
} |
163 |
|
} |