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