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