Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
SchemaConfiguration |
|
| 1.5;1.5 |
1 | package org.jtheque.core.managers.schema; | |
2 | ||
3 | import org.jtheque.core.managers.state.AbstractState; | |
4 | import org.jtheque.utils.bean.Version; | |
5 | ||
6 | /* | |
7 | * This file is part of JTheque. | |
8 | * | |
9 | * JTheque is free software: you can redistribute it and/or modify | |
10 | * it under the terms of the GNU General Public License as published by | |
11 | * the Free Software Foundation, either version 3 of the License. | |
12 | * | |
13 | * JTheque is distributed in the hope that it will be useful, | |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | * GNU General Public License for more details. | |
17 | * | |
18 | * You should have received a copy of the GNU General Public License | |
19 | * along with JTheque. If not, see <http://www.gnu.org/licenses/>. | |
20 | */ | |
21 | ||
22 | /** | |
23 | * The configuration of the schemas. | |
24 | * | |
25 | * @author Baptiste Wicht | |
26 | */ | |
27 | //Must be public for StateManager | |
28 | 0 | public final class SchemaConfiguration extends AbstractState { |
29 | /** | |
30 | * Return the version of the schema. | |
31 | * | |
32 | * @param name The name of the schema. | |
33 | * @return The version of the schema. | |
34 | */ | |
35 | public Version getVersion(String name) { | |
36 | 0 | String property = getProperty(name + "-version", "null"); |
37 | ||
38 | 0 | if ("null".equals(property)) { |
39 | 0 | return null; |
40 | } | |
41 | ||
42 | 0 | return new Version(property); |
43 | } | |
44 | ||
45 | /** | |
46 | * Set the version of the schema. | |
47 | * | |
48 | * @param name The name of the schema. | |
49 | * @param version The version of the schema. | |
50 | */ | |
51 | public void setVersion(String name, Version version) { | |
52 | 0 | setProperty(name + "-version", version.getVersion()); |
53 | 0 | } |
54 | ||
55 | /** | |
56 | * Indicate if the schema has been recovered or not. | |
57 | * | |
58 | * @param name The name of the schema. | |
59 | * @return true if the schema has been recovered else false. | |
60 | */ | |
61 | public boolean isNotRecovered(String name) { | |
62 | 0 | return !Boolean.parseBoolean(getProperty(name + "-recovered", "false")); |
63 | } | |
64 | ||
65 | /** | |
66 | * Mark the schema as recovered. | |
67 | * | |
68 | * @param name The name of the schema. | |
69 | */ | |
70 | public void setRecovered(String name) { | |
71 | 0 | setProperty(name + "-recovered", "true"); |
72 | 0 | } |
73 | } |