1 |
|
package org.kuali.student.contract.mojo; |
2 |
|
|
3 |
|
import java.io.File; |
4 |
|
import java.util.Collection; |
5 |
|
import java.util.List; |
6 |
|
|
7 |
|
import org.apache.maven.plugin.AbstractMojo; |
8 |
|
import org.apache.maven.plugin.MojoExecutionException; |
9 |
|
|
10 |
|
import org.kuali.student.contract.model.ServiceContractModel; |
11 |
|
import org.kuali.student.contract.model.impl.ServiceContractModelCache; |
12 |
|
import org.kuali.student.contract.model.impl.ServiceContractModelQDoxLoader; |
13 |
|
import org.kuali.student.contract.model.util.HtmlContractWriter; |
14 |
|
import org.kuali.student.contract.model.validation.ServiceContractModelValidator; |
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
|
|
| 0% |
Uncovered Elements: 29 (29) |
Complexity: 8 |
Complexity Density: 0.4 |
|
22 |
|
public class KSContractDocMojo extends AbstractMojo { |
23 |
|
|
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
private List<String> sourceDirs; |
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
private File htmlDirectory; |
32 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
33 |
0
|
public File getHtmlDirectory() {... |
34 |
0
|
return htmlDirectory; |
35 |
|
} |
36 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
37 |
0
|
public List<String> getSourceDirs() {... |
38 |
0
|
return sourceDirs; |
39 |
|
} |
40 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
41 |
0
|
public void setHtmlDirectory(File htmlDirectory) {... |
42 |
0
|
this.htmlDirectory = htmlDirectory; |
43 |
|
} |
44 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
45 |
0
|
public void setSourceDirs(List<String> sourceDirs) {... |
46 |
0
|
this.sourceDirs = sourceDirs; |
47 |
|
} |
48 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
49 |
0
|
private ServiceContractModel getModel() {... |
50 |
0
|
ServiceContractModel instance = new ServiceContractModelQDoxLoader( |
51 |
|
sourceDirs); |
52 |
0
|
return new ServiceContractModelCache(instance); |
53 |
|
|
54 |
|
} |
55 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
56 |
0
|
private boolean validate(ServiceContractModel model) {... |
57 |
0
|
Collection<String> errors = new ServiceContractModelValidator(model).validate(); |
58 |
0
|
if (errors.size() > 0) { |
59 |
0
|
StringBuilder buf = new StringBuilder(); |
60 |
0
|
buf.append(errors.size()).append(" errors found while validating the data."); |
61 |
0
|
return false; |
62 |
|
|
63 |
|
|
64 |
|
} |
65 |
0
|
return true; |
66 |
|
} |
67 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
|
68 |
0
|
@Override... |
69 |
|
public void execute() throws MojoExecutionException { |
70 |
0
|
ServiceContractModel model = null; |
71 |
0
|
HtmlContractWriter writer = null; |
72 |
0
|
getLog().info("publishing wiki contracts"); |
73 |
0
|
model = this.getModel(); |
74 |
0
|
this.validate(model); |
75 |
0
|
getLog().info("publishing to = " + this.htmlDirectory.toString()); |
76 |
0
|
writer = new HtmlContractWriter(htmlDirectory.toString(), model); |
77 |
0
|
writer.write(); |
78 |
|
|
79 |
|
|
80 |
|
} |
81 |
|
} |