1 |
|
package org.apache.torque.mojo; |
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
import java.io.File; |
23 |
|
import java.util.Collections; |
24 |
|
import java.util.Comparator; |
25 |
|
import java.util.List; |
26 |
|
import java.util.Vector; |
27 |
|
|
28 |
|
import org.apache.commons.collections.comparators.ReverseComparator; |
29 |
|
import org.apache.maven.plugin.MojoExecutionException; |
30 |
|
import org.apache.torque.util.SimpleScanner; |
31 |
|
import org.apache.torque.util.TransactionComparator; |
32 |
|
import org.kuali.db.jdbc.Transaction; |
33 |
|
|
34 |
|
|
35 |
|
|
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
|
|
|
| 0% |
Uncovered Elements: 46 (46) |
Complexity: 15 |
Complexity Density: 0.54 |
|
40 |
|
public class ImportMojo extends AbstractSQLExecutorMojo { |
41 |
|
private static final String FS = System.getProperty("file.separator"); |
42 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 0 |
Complexity Density: - |
|
43 |
|
public enum Order { |
44 |
|
ASCENDING, DESCENDING, NONE; |
45 |
|
} |
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
|
50 |
|
|
51 |
|
|
52 |
|
|
53 |
|
private File importDir; |
54 |
|
|
55 |
|
|
56 |
|
|
57 |
|
|
58 |
|
private String importDirIncludes; |
59 |
|
|
60 |
|
|
61 |
|
|
62 |
|
|
63 |
|
private String importDirExcludes = ""; |
64 |
|
|
65 |
|
|
66 |
|
|
67 |
|
|
68 |
|
|
69 |
|
|
70 |
|
|
71 |
|
private String order = Order.ASCENDING.toString(); |
72 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
73 |
0
|
protected void updateImportDir() {... |
74 |
0
|
String path = importDir.getAbsolutePath(); |
75 |
0
|
if (!path.endsWith(FS)) { |
76 |
0
|
path += FS; |
77 |
|
} |
78 |
0
|
path += getTargetDatabase(); |
79 |
0
|
importDir = new File(path); |
80 |
|
} |
81 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
|
82 |
0
|
protected Vector<Transaction> getTransactions(List<File> files) {... |
83 |
0
|
Vector<Transaction> transactions = new Vector<Transaction>(); |
84 |
0
|
for (File file : files) { |
85 |
0
|
Transaction t = new Transaction(); |
86 |
0
|
t.setResourceLocation(file.getAbsolutePath()); |
87 |
0
|
transactions.add(t); |
88 |
|
} |
89 |
0
|
return transactions; |
90 |
|
} |
91 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
92 |
0
|
@Override... |
93 |
|
protected void configureTransactions() throws MojoExecutionException { |
94 |
0
|
updateImportDir(); |
95 |
0
|
List<File> files = new SimpleScanner(importDir, importDirIncludes, importDirExcludes).getFiles(); |
96 |
0
|
transactions = getTransactions(files); |
97 |
0
|
sortTransactions(transactions); |
98 |
|
} |
99 |
|
|
100 |
|
|
101 |
|
|
102 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
103 |
0
|
@SuppressWarnings("unchecked")... |
104 |
|
protected void sortTransactions(Vector<Transaction> transactions) { |
105 |
0
|
Comparator<Transaction> comparator = new TransactionComparator<Transaction>(getProject().getArtifactId()); |
106 |
0
|
if (Order.ASCENDING.toString().equals(order)) { |
107 |
0
|
Collections.sort(transactions, comparator); |
108 |
0
|
} else if (Order.DESCENDING.toString().equals(order)) { |
109 |
0
|
Collections.sort(transactions, new ReverseComparator(comparator)); |
110 |
|
} |
111 |
|
} |
112 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
113 |
0
|
public File getImportDir() {... |
114 |
0
|
return importDir; |
115 |
|
} |
116 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
117 |
0
|
public void setImportDir(File importDirectory) {... |
118 |
0
|
this.importDir = importDirectory; |
119 |
|
} |
120 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
121 |
0
|
public String getImportDirIncludes() {... |
122 |
0
|
return importDirIncludes; |
123 |
|
} |
124 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
125 |
0
|
public void setImportDirIncludes(String importDirectoryIncludes) {... |
126 |
0
|
this.importDirIncludes = importDirectoryIncludes; |
127 |
|
} |
128 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
129 |
0
|
public String getImportDirExcludes() {... |
130 |
0
|
return importDirExcludes; |
131 |
|
} |
132 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
133 |
0
|
public void setImportDirExcludes(String importDirectoryExcludes) {... |
134 |
0
|
this.importDirExcludes = importDirectoryExcludes; |
135 |
|
} |
136 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
137 |
0
|
public String getOrder() {... |
138 |
0
|
return order; |
139 |
|
} |
140 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
141 |
0
|
public void setOrder(String order) {... |
142 |
0
|
this.order = order; |
143 |
|
} |
144 |
|
} |