1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
package org.qedeq.kernel.bo.service.basis; |
17 |
|
|
18 |
|
import java.lang.reflect.InvocationTargetException; |
19 |
|
|
20 |
|
import org.qedeq.base.io.Parameters; |
21 |
|
import org.qedeq.base.io.SourceArea; |
22 |
|
import org.qedeq.base.test.DynamicGetter; |
23 |
|
import org.qedeq.base.trace.Trace; |
24 |
|
import org.qedeq.base.utility.YodaUtility; |
25 |
|
import org.qedeq.kernel.bo.common.Element2Utf8; |
26 |
|
import org.qedeq.kernel.bo.job.InternalModuleServiceCallImpl; |
27 |
|
import org.qedeq.kernel.bo.module.InternalKernelServices; |
28 |
|
import org.qedeq.kernel.bo.module.InternalModuleServiceCall; |
29 |
|
import org.qedeq.kernel.bo.module.InternalServiceJob; |
30 |
|
import org.qedeq.kernel.bo.module.KernelQedeqBo; |
31 |
|
import org.qedeq.kernel.bo.module.ModuleLabels; |
32 |
|
import org.qedeq.kernel.bo.module.QedeqFileDao; |
33 |
|
import org.qedeq.kernel.bo.service.internal.DefaultInternalKernelServices; |
34 |
|
import org.qedeq.kernel.bo.service.internal.DefaultKernelQedeqBo; |
35 |
|
import org.qedeq.kernel.bo.service.internal.Element2LatexImpl; |
36 |
|
import org.qedeq.kernel.bo.service.internal.Element2Utf8Impl; |
37 |
|
import org.qedeq.kernel.bo.service.internal.ServiceProcessManager; |
38 |
|
import org.qedeq.kernel.bo.service.latex.QedeqBoDuplicateLanguageChecker; |
39 |
|
import org.qedeq.kernel.bo.test.DummyPlugin; |
40 |
|
import org.qedeq.kernel.bo.test.KernelFacade; |
41 |
|
import org.qedeq.kernel.se.base.module.Qedeq; |
42 |
|
import org.qedeq.kernel.se.common.ModuleAddress; |
43 |
|
import org.qedeq.kernel.se.common.ModuleDataException; |
44 |
|
import org.qedeq.kernel.se.common.SourceFileExceptionList; |
45 |
|
import org.qedeq.kernel.se.dto.module.QedeqVo; |
46 |
|
import org.qedeq.kernel.se.state.LoadingState; |
47 |
|
import org.qedeq.kernel.se.visitor.InterruptException; |
48 |
|
import org.qedeq.kernel.xml.dao.XmlQedeqFileDao; |
49 |
|
import org.qedeq.kernel.xml.mapper.Context2SimpleXPath; |
50 |
|
import org.qedeq.kernel.xml.tracker.SimpleXPath; |
51 |
|
import org.qedeq.kernel.xml.tracker.XPathLocationParser; |
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
|
56 |
|
@author |
57 |
|
|
|
|
| 70.4% |
Uncovered Elements: 24 (81) |
Complexity: 19 |
Complexity Density: 0.28 |
|
58 |
|
public class QedeqBoFactoryAssert extends QedeqVoBuilder { |
59 |
|
|
60 |
|
|
61 |
|
private static final Class CLASS = QedeqBoFactoryAssert.class; |
62 |
|
|
63 |
|
|
64 |
|
|
65 |
|
|
66 |
|
@param |
67 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
68 |
18
|
public QedeqBoFactoryAssert(final ModuleAddress address) {... |
69 |
18
|
super(address); |
70 |
|
} |
71 |
|
|
|
|
| 66.7% |
Uncovered Elements: 1 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
72 |
54
|
public static DefaultInternalKernelServices getInternalServices() {... |
73 |
54
|
try { |
74 |
54
|
return (DefaultInternalKernelServices) YodaUtility.getFieldValue( |
75 |
|
KernelFacade.getKernelContext(), "services"); |
76 |
|
} catch (NoSuchFieldException e) { |
77 |
0
|
throw new RuntimeException(e); |
78 |
|
} |
79 |
|
} |
80 |
|
|
|
|
| 71.4% |
Uncovered Elements: 2 (7) |
Complexity: 2 |
Complexity Density: 0.29 |
|
81 |
18
|
public static InternalModuleServiceCall createServiceCall(final String name, final KernelQedeqBo prop)... |
82 |
|
throws InterruptException { |
83 |
18
|
final InternalServiceJob process; |
84 |
18
|
try { |
85 |
18
|
process = ((ServiceProcessManager) YodaUtility.getFieldValue(getInternalServices(), "processManager")) |
86 |
|
.createServiceProcess(name); |
87 |
|
} catch (NoSuchFieldException e) { |
88 |
0
|
e.printStackTrace(); |
89 |
0
|
throw new RuntimeException(e); |
90 |
|
} |
91 |
18
|
final InternalModuleServiceCallImpl call = new InternalModuleServiceCallImpl(DummyPlugin.getInstance(), prop, Parameters.EMPTY, Parameters.EMPTY, process, null); |
92 |
18
|
return call; |
93 |
|
} |
94 |
|
|
|
|
| 50% |
Uncovered Elements: 4 (8) |
Complexity: 3 |
Complexity Density: 0.5 |
|
95 |
18
|
public static void endServiceCall(final InternalModuleServiceCall call) {... |
96 |
18
|
if (call == null) { |
97 |
0
|
return; |
98 |
|
} |
99 |
18
|
try { |
100 |
18
|
((ServiceProcessManager) YodaUtility.getFieldValue(getInternalServices(), "processManager")) |
101 |
|
.endServiceCall(call); |
102 |
|
} catch (NoSuchFieldException e) { |
103 |
0
|
e.printStackTrace(); |
104 |
0
|
throw new RuntimeException(e); |
105 |
|
} |
106 |
|
} |
107 |
|
|
108 |
|
|
109 |
|
@link@link |
110 |
|
|
111 |
|
|
112 |
|
|
113 |
|
@link |
114 |
|
|
115 |
|
|
116 |
|
@link |
117 |
|
|
118 |
|
@param |
119 |
|
@param |
120 |
|
|
|
|
| 82.1% |
Uncovered Elements: 5 (28) |
Complexity: 3 |
Complexity Density: 0.12 |
|
121 |
18
|
public static void createQedeq(final DefaultKernelQedeqBo prop,... |
122 |
|
final Qedeq original) throws SourceFileExceptionList, InterruptException { |
123 |
18
|
final QedeqBoFactoryAssert creator = new QedeqBoFactoryAssert(prop.getModuleAddress()); |
124 |
18
|
final QedeqVo vo; |
125 |
18
|
try { |
126 |
18
|
vo = creator.create(original); |
127 |
|
} catch (ModuleDataException e) { |
128 |
0
|
final SourceFileExceptionList xl |
129 |
|
= prop.createSourceFileExceptionList(DummyPlugin.getInstance(), e, original); |
130 |
0
|
prop.setLoadingFailureState(LoadingState.STATE_LOADING_INTO_MEMORY_FAILED, xl); |
131 |
0
|
throw xl; |
132 |
|
} |
133 |
18
|
final QedeqFileDao loader = new XmlQedeqFileDao(); |
134 |
18
|
loader.setServices(getInternalServices()); |
135 |
18
|
prop.setQedeqFileDao(loader); |
136 |
18
|
prop.setQedeqVo(vo); |
137 |
18
|
final ModuleLabelsCreator mc = new ModuleLabelsCreator(DummyPlugin.getInstance(), |
138 |
|
prop); |
139 |
18
|
InternalModuleServiceCall call = null; |
140 |
18
|
final ModuleLabels labels = new ModuleLabels(); |
141 |
18
|
final Element2LatexImpl converter = new Element2LatexImpl(labels); |
142 |
18
|
final Element2Utf8 textConverter = new Element2Utf8Impl(converter); |
143 |
18
|
try { |
144 |
18
|
call = createServiceCall("createQedeq", prop); |
145 |
18
|
mc.createLabels(call.getInternalServiceProcess(), labels); |
146 |
|
} finally { |
147 |
18
|
endServiceCall(call); |
148 |
|
} |
149 |
17
|
prop.setLoaded(vo, labels, converter, textConverter); |
150 |
17
|
KernelFacade.getKernelContext().loadRequiredModules(prop.getModuleAddress()); |
151 |
17
|
KernelFacade.getKernelContext().checkWellFormedness(prop.getModuleAddress()); |
152 |
17
|
if (!prop.isWellFormed()) { |
153 |
0
|
throw prop.getErrors(); |
154 |
|
} |
155 |
17
|
QedeqBoDuplicateLanguageChecker.check(call); |
156 |
|
} |
157 |
|
|
158 |
|
|
159 |
|
|
160 |
|
|
161 |
|
@param |
162 |
|
|
|
|
| 57.1% |
Uncovered Elements: 12 (28) |
Complexity: 8 |
Complexity Density: 0.33 |
|
163 |
58656
|
protected void setLocationWithinModule(final String locationWithinModule) {... |
164 |
58656
|
Trace.param(CLASS, "setLocationWithinModule(String)", |
165 |
|
"locationWithinModule > ", locationWithinModule); |
166 |
58656
|
getCurrentContext().setLocationWithinModule(locationWithinModule); |
167 |
|
|
168 |
58656
|
try { |
169 |
58656
|
DynamicGetter.get(getQedeqOriginal(), getCurrentContext().getLocationWithinModule()); |
170 |
|
} catch (RuntimeException e) { |
171 |
0
|
System.err.println(getCurrentContext().getLocationWithinModule()); |
172 |
0
|
throw e; |
173 |
|
} catch (IllegalAccessException e) { |
174 |
0
|
throw new RuntimeException(e); |
175 |
|
} catch (InvocationTargetException e) { |
176 |
0
|
throw new RuntimeException(e); |
177 |
|
} |
178 |
|
|
179 |
58656
|
SimpleXPath xpath; |
180 |
58656
|
try { |
181 |
58656
|
xpath = Context2SimpleXPath.getXPath(getCurrentContext(), getQedeqOriginal()); |
182 |
|
} catch (ModuleDataException e) { |
183 |
0
|
throw new RuntimeException(e); |
184 |
|
} |
185 |
58656
|
Trace.param(CLASS, "setLocationWithinModule(String)", |
186 |
|
"xpath < ", xpath); |
187 |
58656
|
InternalKernelServices services; |
188 |
58656
|
try { |
189 |
58656
|
services = (InternalKernelServices) YodaUtility |
190 |
|
.getFieldValue(KernelFacade.getKernelContext(), "services"); |
191 |
|
} catch (NoSuchFieldException e) { |
192 |
0
|
throw new RuntimeException(e); |
193 |
|
} |
194 |
58656
|
final SourceArea find = XPathLocationParser.findSourceArea( |
195 |
|
services.getLocalFilePath( |
196 |
|
getCurrentContext().getModuleLocation()), xpath); |
197 |
58656
|
if (find.getStartPosition() == null) { |
198 |
0
|
System.out.println(getCurrentContext()); |
199 |
0
|
throw new RuntimeException("start not found: " + find + "\ncontext: " |
200 |
|
+ getCurrentContext().getLocationWithinModule()); |
201 |
|
} |
202 |
58656
|
if (find.getEndPosition() == null) { |
203 |
0
|
System.out.println(getCurrentContext()); |
204 |
0
|
throw new RuntimeException("end not found: " + find + "\ncontext: " |
205 |
|
+ getCurrentContext().getLocationWithinModule()); |
206 |
|
} |
207 |
|
} |
208 |
|
} |