|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
KernelQedeqBoStorage | Line # 38 | 62 | 19 | 61,1% |
0.6111111
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||
(38) | |||
Result | |||
0.43333334
|
org.qedeq.kernel.bo.latex.GenerateLatexTest.testNegative08
![]() |
1 PASS | |
0.43333334
|
org.qedeq.kernel.bo.control.QedeqBoFactoryTest.testCreateStringQedeq5
![]() |
1 PASS | |
0.43333334
|
org.qedeq.kernel.bo.latex.GenerateLatexTest.testGeneration
![]() |
1 PASS | |
0.43333334
|
org.qedeq.kernel.bo.latex.GenerateLatexTest.testNegative06
![]() |
1 PASS | |
0.43333334
|
org.qedeq.kernel.bo.latex.GenerateLatexTest.testGeneration
![]() |
1 PASS | |
0.43333334
|
org.qedeq.kernel.bo.latex.GenerateLatexTest.testNegative05
![]() |
1 PASS | |
0.43333334
|
org.qedeq.kernel.bo.latex.GenerateLatexTest.testNegative06
![]() |
1 PASS | |
0.43333334
|
org.qedeq.kernel.bo.latex.GenerateLatexTest.testNegative07
![]() |
1 PASS | |
0.43333334
|
org.qedeq.kernel.bo.latex.ExtendedGenerateLatexTest.testGeneration
![]() |
1 PASS | |
0.43333334
|
org.qedeq.kernel.bo.latex.GenerateLatexTest.testNegative08
![]() |
1 PASS | |
0.43333334
|
org.qedeq.kernel.bo.latex.GenerateLatexTest.testNegative07
![]() |
1 PASS | |
0.43333334
|
org.qedeq.kernel.bo.control.QedeqBoFactoryTest.testCreateStringQedeq4
![]() |
1 PASS | |
0.43333334
|
org.qedeq.kernel.bo.latex.GenerateLatexTest.testNegative05
![]() |
1 PASS | |
0.32222223
|
org.qedeq.kernel.bo.control.QedeqBoFactoryTest.testCreateStringQedeq3
![]() |
1 PASS | |
0.32222223
|
org.qedeq.kernel.bo.control.QedeqBoFactoryTest.testCreateStringQedeq2
![]() |
1 PASS | |
0.32222223
|
org.qedeq.kernel.xml.parser.CharsetParserTest.testParse2
![]() |
1 PASS | |
0.32222223
|
org.qedeq.kernel.bo.control.QedeqBoFactoryTest.testCreateStringQedeq6
![]() |
1 PASS | |
0.32222223
|
org.qedeq.kernel.xml.parser.CharsetParserTest.testParse1
![]() |
1 PASS | |
0.08888889
|
org.qedeq.kernel.bo.control.LoadRequiredModulesTest.testLoadRequiredModules_06
![]() |
1 PASS | |
0.08888889
|
org.qedeq.kernel.bo.control.LoadRequiredModulesTest.testLoadRequiredModules_05
![]() |
1 PASS | |
0.08888889
|
org.qedeq.kernel.bo.control.LoadRequiredModulesTest.testLoadRequiredModules_07
![]() |
1 PASS | |
0.08888889
|
org.qedeq.kernel.bo.control.LoadRequiredModulesTest.testLoadRequiredModules_04
![]() |
1 PASS | |
0.08888889
|
org.qedeq.kernel.bo.control.LoadRequiredModulesTest.testLoadRequiredModules_01
![]() |
1 PASS | |
0.08888889
|
org.qedeq.kernel.bo.control.LoadRequiredModulesTest.testLoadRequiredModules_09
![]() |
1 PASS | |
0.08888889
|
org.qedeq.kernel.bo.control.LoadRequiredModulesTest.testLoadRequiredModules_02
![]() |
1 PASS | |
0.06666667
|
org.qedeq.kernel.bo.control.LoadRequiredModulesTest.testLoadRequiredModules_08
![]() |
1 PASS | |
0.06666667
|
org.qedeq.kernel.xml.dao.GenerateXmlTest.testGeneration
![]() |
1 PASS | |
0.06666667
|
org.qedeq.kernel.bo.latex.GenerateLatexTest.testNegative03
![]() |
1 PASS | |
0.06666667
|
org.qedeq.kernel.bo.control.LoadRequiredModulesTest.testLoadRequiredModules_03
![]() |
1 PASS | |
0.06666667
|
org.qedeq.kernel.bo.latex.GenerateLatexTest.testNegative04
![]() |
1 PASS | |
0.06666667
|
org.qedeq.kernel.bo.control.QedeqBoFactoryTest.testCreateStringQedeq1
![]() |
1 PASS | |
0.06666667
|
org.qedeq.kernel.bo.logic.wf.CheckLogicTest.testNegative02
![]() |
1 PASS | |
0.06666667
|
org.qedeq.kernel.bo.latex.GenerateLatexTest.testNegative02
![]() |
1 PASS | |
0.06666667
|
org.qedeq.kernel.bo.latex.GenerateLatexTest.testNegative03
![]() |
1 PASS | |
0.06666667
|
org.qedeq.kernel.bo.latex.GenerateLatexTest.testNegative04
![]() |
1 PASS | |
0.06666667
|
org.qedeq.kernel.bo.latex.GenerateLatexTest.testNegative02
![]() |
1 PASS | |
0.06666667
|
org.qedeq.kernel.bo.logic.wf.CheckLogicTest.testNegative04
![]() |
1 PASS | |
0.06666667
|
org.qedeq.kernel.bo.logic.wf.CheckLogicTest.testNegative03
![]() |
1 PASS | |
1 | /* $Id: KernelQedeqBoStorage.java,v 1.1 2008/07/26 07:58:28 m31 Exp $ | |
2 | * | |
3 | * This file is part of the project "Hilbert II" - http://www.qedeq.org | |
4 | * | |
5 | * Copyright 2000-2008, 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.service; | |
19 | ||
20 | import java.util.ArrayList; | |
21 | import java.util.HashMap; | |
22 | import java.util.Iterator; | |
23 | import java.util.List; | |
24 | import java.util.Map; | |
25 | ||
26 | import org.qedeq.base.io.IoUtility; | |
27 | import org.qedeq.base.trace.Trace; | |
28 | import org.qedeq.kernel.bo.QedeqBo; | |
29 | import org.qedeq.kernel.bo.module.InternalKernelServices; | |
30 | import org.qedeq.kernel.bo.module.KernelModuleReferenceList; | |
31 | import org.qedeq.kernel.bo.module.KernelQedeqBo; | |
32 | import org.qedeq.kernel.common.LoadingState; | |
33 | import org.qedeq.kernel.common.ModuleAddress; | |
34 | ||
35 | /** | |
36 | * Holds all known QEDEQ modules. | |
37 | */ | |
38 | class KernelQedeqBoStorage { | |
39 | ||
40 | /** This class. */ | |
41 | private static final Class CLASS = KernelQedeqBoStorage.class; | |
42 | ||
43 | /** QEDEQ Modules; key: ModuleAddress, value: KernelQedeqBo. */ | |
44 | private final Map bos = new HashMap(); | |
45 | ||
46 | ||
47 | /** | |
48 | * Get {@link QedeqBo} for an module address. If it is unknown it will be created. | |
49 | * | |
50 | * @param services Internal kernel services. | |
51 | * @param address Module address. | |
52 | * @return QedeqBo for module. | |
53 | */ | |
54 | 472 |
![]() |
55 | final ModuleAddress address) { | |
56 | 472 | if (bos.containsKey(address)) { |
57 | 347 | return (DefaultKernelQedeqBo) bos.get(address); |
58 | } else { | |
59 | 125 | final DefaultKernelQedeqBo prop = new DefaultKernelQedeqBo(services, address); |
60 | 125 | bos.put(address, prop); |
61 | 125 | return prop; |
62 | } | |
63 | } | |
64 | ||
65 | /** | |
66 | * Remove all modules from memory. | |
67 | */ | |
68 | 0 |
![]() |
69 | 0 | final String method = "removeAllModules()"; |
70 | 0 | Trace.begin(CLASS, this, method); |
71 | 0 | try { |
72 | 0 | for (final Iterator iterator |
73 | = bos.entrySet().iterator(); | |
74 | 0 | iterator.hasNext(); ) { |
75 | 0 | Map.Entry entry = (Map.Entry) iterator.next(); |
76 | 0 | final DefaultKernelQedeqBo prop = (DefaultKernelQedeqBo) entry.getValue(); |
77 | 0 | prop.delete(); |
78 | } | |
79 | 0 | bos.clear(); |
80 | } catch (RuntimeException e) { | |
81 | 0 | Trace.trace(CLASS, this, method, e); |
82 | } finally { | |
83 | 0 | Trace.end(CLASS, this, method); |
84 | } | |
85 | } | |
86 | ||
87 | /** | |
88 | * Validate module dependencies and throw Error if they are not correct. | |
89 | */ | |
90 | 74 |
![]() |
91 | 74 | final String method = "validateDependencies"; |
92 | 74 | boolean error = false; |
93 | 74 | Trace.begin(CLASS, this, method); |
94 | 511 | for (final Iterator iterator = bos.entrySet().iterator(); iterator.hasNext(); ) { |
95 | 437 | Map.Entry entry = (Map.Entry) iterator.next(); |
96 | 437 | final DefaultKernelQedeqBo prop = (DefaultKernelQedeqBo) entry.getValue(); |
97 | 437 | Trace.param(CLASS, this, method, "prop", prop); |
98 | 437 | if (!prop.hasLoadedRequiredModules()) { |
99 | 0 | continue; |
100 | } | |
101 | ||
102 | // prop must be in dependent list for all required modules | |
103 | 437 | final KernelModuleReferenceList refs = prop.getKernelRequiredModules(); |
104 | 648 | for (int i = 0; i < refs.size(); i++) { |
105 | 211 | final KernelQedeqBo ref = refs.getKernelQedeqBo(i); |
106 | 211 | final KernelModuleReferenceList dependents = (KernelModuleReferenceList) |
107 | IoUtility.getFieldContent(ref, "dependent"); // TODO mime 20080325: Q & D | |
108 | 211 | if (!dependents.contains(prop)) { |
109 | 0 | Trace.fatal(CLASS, this, method, ref.getUrl() + " missing dependent module: " |
110 | + prop.getUrl(), null); | |
111 | 0 | error = true; |
112 | } | |
113 | } | |
114 | ||
115 | // for all dependent modules, prop must be in required list | |
116 | 437 | final KernelModuleReferenceList dependents = prop.getDependentModules(); |
117 | 648 | for (int i = 0; i < dependents.size(); i++) { |
118 | 211 | final KernelQedeqBo dependent = dependents.getKernelQedeqBo(i); |
119 | 211 | final KernelModuleReferenceList refs2 = (KernelModuleReferenceList) |
120 | IoUtility.getFieldContent(dependent, "required"); | |
121 | 211 | if (!refs2.contains(prop)) { // TODO mime 20080325: Q & D |
122 | 0 | Trace.fatal(CLASS, this, method, dependent.getUrl() |
123 | + " missing required module: " + prop.getUrl(), null); | |
124 | 0 | error = true; |
125 | } | |
126 | } | |
127 | } | |
128 | 74 | Trace.end(CLASS, this, method); |
129 | ||
130 | // if the dependencies are not ok we throw an error! | |
131 | 74 | if (error) { |
132 | 0 | Error e = new Error("QEDEQ dependencies and status are flawed! This is a major error!"); |
133 | 0 | Trace.fatal(CLASS, this, method, "Shutdown because of major validation error", e); |
134 | 0 | throw e; |
135 | } | |
136 | } | |
137 | ||
138 | /** | |
139 | * Remove a QEDEQ module from memory. | |
140 | * | |
141 | * @param prop Defines the module. | |
142 | */ | |
143 | 0 |
![]() |
144 | 0 | final String method = "removeModule(KernelQedeqBo)"; |
145 | 0 | Trace.begin(CLASS, this, method); |
146 | 0 | try { |
147 | 0 | Trace.trace(CLASS, this, method, "removing " + prop.getUrl()); |
148 | 0 | bos.remove(prop.getModuleAddress()); |
149 | } catch (RuntimeException e) { | |
150 | 0 | Trace.trace(CLASS, this, method, e); |
151 | } finally { | |
152 | 0 | Trace.end(CLASS, this, method); |
153 | } | |
154 | } | |
155 | ||
156 | /** | |
157 | * Get list of all successfully loaded modules. | |
158 | * | |
159 | * @return list of all successfully loaded modules. | |
160 | */ | |
161 | 39 |
![]() |
162 | 39 | final String method = "getAllModules()"; |
163 | 39 | Trace.begin(CLASS, this, method); |
164 | 39 | try { |
165 | 39 | final List list = new ArrayList(); |
166 | 164 | for (final Iterator iterator = bos.entrySet().iterator(); iterator.hasNext(); ) { |
167 | 125 | Map.Entry entry = (Map.Entry) iterator.next(); |
168 | 125 | final QedeqBo prop = (QedeqBo) entry.getValue(); |
169 | 125 | if (prop.getLoadingState().getCode() >= LoadingState.STATE_LOADED.getCode()) { |
170 | 117 | list.add(prop.getModuleAddress()); |
171 | } | |
172 | } | |
173 | 39 | return (ModuleAddress[]) list.toArray(new ModuleAddress[] {}); |
174 | } finally { | |
175 | 39 | Trace.end(CLASS, this, method); |
176 | } | |
177 | } | |
178 | ||
179 | /** | |
180 | * Get number of QEDEQ modules in STATE_LOADED. | |
181 | * | |
182 | * @return Number of loaded modules. | |
183 | */ | |
184 | 0 |
![]() |
185 | 0 | return getAllLoadedModules().length; |
186 | } | |
187 | ||
188 | } |
|