1 |
|
package org.apache.torque.mojo.morph; |
2 |
|
|
3 |
|
import org.apache.commons.lang.StringUtils; |
4 |
|
import org.apache.commons.logging.Log; |
5 |
|
import org.apache.commons.logging.LogFactory; |
6 |
|
|
|
|
| 0% |
Uncovered Elements: 72 (72) |
Complexity: 27 |
Complexity Density: 0.69 |
|
7 |
|
public class SchemaMorpher extends Morpher { |
8 |
|
private static final Log log = LogFactory.getLog(SchemaMorpher.class); |
9 |
|
|
10 |
|
|
11 |
|
String antSchemaName = "kfs"; |
12 |
|
|
13 |
|
String antSchemaToken = "name=\"" + antSchemaName + "\""; |
14 |
|
|
15 |
|
String antDTDString = "\"database.dtd\""; |
16 |
|
|
17 |
|
String newDTDString = "\"http://www.kuali.org/dtd/database.dtd\""; |
18 |
|
|
19 |
|
String antComment = "<!-- Autogenerated by KualiTorqueJDBCTransformTask! -->"; |
20 |
|
|
21 |
|
String newComment = "<!-- Autogenerated by the Maven Impex Plugin -->"; |
22 |
|
|
23 |
|
String antPrologue = "<?xml version=\"1.0\"?>"; |
24 |
|
|
25 |
|
String newPrologue = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"; |
26 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
27 |
0
|
public SchemaMorpher() {... |
28 |
0
|
this(null, null); |
29 |
|
} |
30 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
31 |
0
|
public SchemaMorpher(MorphRequest morphRequest, String artifactId) {... |
32 |
0
|
super(); |
33 |
0
|
this.artifactId = artifactId; |
34 |
0
|
this.morphRequest = morphRequest; |
35 |
|
} |
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
|
|
|
| 0% |
Uncovered Elements: 17 (17) |
Complexity: 5 |
Complexity Density: 0.56 |
|
40 |
0
|
protected boolean isAntImpexSchemaXML(String contents) {... |
41 |
0
|
if (contents == null) { |
42 |
0
|
return false; |
43 |
|
} |
44 |
0
|
if (contents.indexOf(antSchemaToken) == -1) { |
45 |
0
|
return false; |
46 |
|
} |
47 |
0
|
if (contents.indexOf(antDTDString) == -1) { |
48 |
0
|
return false; |
49 |
|
} |
50 |
0
|
if (contents.indexOf(antComment) == -1) { |
51 |
0
|
return false; |
52 |
|
} |
53 |
|
|
54 |
|
|
55 |
0
|
return true; |
56 |
|
} |
57 |
|
|
58 |
|
|
59 |
|
|
60 |
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 3 |
Complexity Density: 0.5 |
|
61 |
0
|
protected boolean isMorphNeeded(String contents) {... |
62 |
0
|
if (!isAntImpexSchemaXML(contents)) { |
63 |
0
|
log.warn("Unable to determine if this is a schema exported from Ant Impex"); |
64 |
|
} |
65 |
|
|
66 |
|
|
67 |
0
|
int pos = contents.indexOf(newDTDString); |
68 |
|
|
69 |
0
|
if (pos == -1) { |
70 |
|
|
71 |
0
|
return true; |
72 |
|
} else { |
73 |
|
|
74 |
0
|
return false; |
75 |
|
} |
76 |
|
} |
77 |
|
|
78 |
|
|
79 |
|
|
80 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
81 |
0
|
@Override... |
82 |
|
protected String getMorphedContents(String contents) { |
83 |
0
|
contents = StringUtils.replace(contents, antDTDString, newDTDString); |
84 |
0
|
contents = StringUtils.replace(contents, antComment, newComment); |
85 |
0
|
contents = StringUtils.replace(contents, antPrologue, newPrologue); |
86 |
0
|
return StringUtils.replace(contents, "name=\"" + antSchemaName + "\">", "name=\"" + getArtifactId() + "\">"); |
87 |
|
} |
88 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
89 |
0
|
public String getAntSchemaName() {... |
90 |
0
|
return antSchemaName; |
91 |
|
} |
92 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
93 |
0
|
public void setAntSchemaName(String defaultSchemaName) {... |
94 |
0
|
this.antSchemaName = defaultSchemaName; |
95 |
|
} |
96 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
97 |
0
|
public String getAntSchemaToken() {... |
98 |
0
|
return antSchemaToken; |
99 |
|
} |
100 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
101 |
0
|
public void setAntSchemaToken(String defaultSchemaToken) {... |
102 |
0
|
this.antSchemaToken = defaultSchemaToken; |
103 |
|
} |
104 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
105 |
0
|
public String getAntDTDString() {... |
106 |
0
|
return antDTDString; |
107 |
|
} |
108 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
109 |
0
|
public void setAntDTDString(String defaultDTDString) {... |
110 |
0
|
this.antDTDString = defaultDTDString; |
111 |
|
} |
112 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
113 |
0
|
public String getNewDTDString() {... |
114 |
0
|
return newDTDString; |
115 |
|
} |
116 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
117 |
0
|
public void setNewDTDString(String newDTDString) {... |
118 |
0
|
this.newDTDString = newDTDString; |
119 |
|
} |
120 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
121 |
0
|
public String getAntComment() {... |
122 |
0
|
return antComment; |
123 |
|
} |
124 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
125 |
0
|
public void setAntComment(String defaultComment) {... |
126 |
0
|
this.antComment = defaultComment; |
127 |
|
} |
128 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
129 |
0
|
public String getNewComment() {... |
130 |
0
|
return newComment; |
131 |
|
} |
132 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
133 |
0
|
public void setNewComment(String newComment) {... |
134 |
0
|
this.newComment = newComment; |
135 |
|
} |
136 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
137 |
0
|
public String getAntPrologue() {... |
138 |
0
|
return antPrologue; |
139 |
|
} |
140 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
141 |
0
|
public void setAntPrologue(String antPrologue) {... |
142 |
0
|
this.antPrologue = antPrologue; |
143 |
|
} |
144 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
145 |
0
|
public String getNewPrologue() {... |
146 |
0
|
return newPrologue; |
147 |
|
} |
148 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
149 |
0
|
public void setNewPrologue(String newPrologue) {... |
150 |
0
|
this.newPrologue = newPrologue; |
151 |
|
} |
152 |
|
|
153 |
|
} |