1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package com.xpn.xwiki.store.migration.hibernate; |
22 |
|
|
23 |
|
import javax.inject.Inject; |
24 |
|
import javax.inject.Named; |
25 |
|
|
26 |
|
import org.xwiki.component.manager.ComponentLookupException; |
27 |
|
import org.xwiki.component.manager.ComponentManager; |
28 |
|
import org.xwiki.context.Execution; |
29 |
|
import org.xwiki.context.ExecutionContext; |
30 |
|
|
31 |
|
import com.xpn.xwiki.XWikiContext; |
32 |
|
import com.xpn.xwiki.XWikiException; |
33 |
|
import com.xpn.xwiki.store.XWikiHibernateBaseStore; |
34 |
|
import com.xpn.xwiki.store.XWikiStoreInterface; |
35 |
|
import com.xpn.xwiki.store.migration.DataMigrationException; |
36 |
|
import com.xpn.xwiki.store.migration.XWikiDBVersion; |
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
@see |
42 |
|
@version |
43 |
|
@since |
44 |
|
|
|
|
| 12% |
Uncovered Elements: 22 (25) |
Complexity: 10 |
Complexity Density: 0.62 |
|
45 |
|
public abstract class AbstractHibernateDataMigration implements HibernateDataMigration |
46 |
|
{ |
47 |
|
|
48 |
|
|
49 |
|
|
50 |
|
@Inject |
51 |
|
protected ComponentManager componentManager; |
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
|
56 |
|
@Inject |
57 |
|
private Execution execution; |
58 |
|
|
59 |
|
|
60 |
|
@return |
61 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
62 |
23 |
protected XWikiContext getXWikiContext()... |
63 |
|
{ |
64 |
23 |
ExecutionContext context = this.execution.getContext(); |
65 |
23 |
return (XWikiContext) context.getProperty("xwikicontext"); |
66 |
|
} |
67 |
|
|
68 |
|
|
69 |
|
@return |
70 |
|
@throws |
71 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
72 |
0 |
protected XWikiHibernateBaseStore getStore() throws DataMigrationException... |
73 |
|
{ |
74 |
0 |
try { |
75 |
0 |
return (XWikiHibernateBaseStore) this.componentManager.getInstance(XWikiStoreInterface.class, "hibernate"); |
76 |
|
} catch (ComponentLookupException e) { |
77 |
0 |
throw new DataMigrationException(String.format("Unable to reach the store for database %s", |
78 |
|
getXWikiContext().getWikiId()), e); |
79 |
|
} |
80 |
|
} |
81 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
82 |
0 |
@Override... |
83 |
|
public String getName() |
84 |
|
{ |
85 |
0 |
String hint = null; |
86 |
0 |
Named named = this.getClass().getAnnotation(Named.class); |
87 |
0 |
if (named != null) { |
88 |
0 |
hint = named.value(); |
89 |
|
} |
90 |
0 |
return hint; |
91 |
|
} |
92 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
93 |
0 |
@Override... |
94 |
|
public boolean shouldExecute(XWikiDBVersion startupVersion) |
95 |
|
{ |
96 |
0 |
return true; |
97 |
|
} |
98 |
|
|
99 |
|
|
100 |
|
|
101 |
|
|
102 |
|
@throws |
103 |
|
@throws |
104 |
|
|
105 |
|
protected abstract void hibernateMigrate() throws DataMigrationException, XWikiException; |
106 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
107 |
0 |
@Override... |
108 |
|
public void migrate() throws DataMigrationException |
109 |
|
{ |
110 |
0 |
try { |
111 |
0 |
hibernateMigrate(); |
112 |
|
} catch (Exception e) { |
113 |
0 |
throw new DataMigrationException(String.format("Data migration %s failed", getName()), e); |
114 |
|
} |
115 |
|
} |
116 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
117 |
0 |
@Override... |
118 |
|
public String getPreHibernateLiquibaseChangeLog() throws DataMigrationException |
119 |
|
{ |
120 |
0 |
return null; |
121 |
|
} |
122 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
123 |
0 |
@Override... |
124 |
|
public String getLiquibaseChangeLog() throws DataMigrationException |
125 |
|
{ |
126 |
0 |
return null; |
127 |
|
} |
128 |
|
} |