1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.student.admin.ui.mojo;
17
18 import java.util.ArrayList;
19 import java.util.HashMap;
20 import java.util.List;
21 import java.util.Map;
22
23 import org.apache.maven.plugin.MojoExecutionException;
24 import org.apache.maven.plugin.MojoFailureException;
25 import org.apache.maven.project.MavenProject;
26 import org.kuali.student.common.mojo.AbstractKSMojo;
27 import org.kuali.student.contract.model.ServiceContractModel;
28 import org.kuali.student.contract.model.util.ServicesFilterByKeys;
29 import org.slf4j.Logger;
30 import org.slf4j.LoggerFactory;
31
32
33
34
35
36
37
38
39
40 public class KSCreateAdminUiMojo extends AbstractKSMojo {
41
42 private static final Logger log = LoggerFactory.getLogger(KSCreateAdminUiMojo.class);
43
44 public KSCreateAdminUiMojo() {
45 }
46 public String targetDir;
47
48 public String getTargetDir() {
49 return targetDir;
50 }
51
52 public void setTargetDir(String targetDir) {
53 this.targetDir = targetDir;
54 }
55
56 @Override
57 public void execute() throws MojoExecutionException, MojoFailureException {
58 ServiceContractModel model = getModel();
59 validate(model);
60 if (targetDir == null) {
61 targetDir = "target/generated-sources/admin-ui";
62 }
63
64 List<String> servKeys = new ArrayList<String>();
65 servKeys.add("Atp");
66 servKeys.add("Type");
67 servKeys.add("State");
68 servKeys.add("LRC");
69 ServicesFilterByKeys filter = new ServicesFilterByKeys(servKeys);
70
71 AdminUiWriter instance =
72 new AdminUiWriter(model,
73 targetDir,
74 AdminUiWriter.DEFAULT_ROOT_PACKAGE,
75
76 filter);
77 instance.write();
78
79 }
80 private static final String CORE_DIRECTORY = "D:/svn/ks/trunk/ks-api/ks-core-api/src/main";
81
82 private static final String COMMON_DIRECTORY = "D:/svn/ks/trunk/ks-api/ks-common-api/src/main/java";
83 private static final String ENROLL_DIRECTORY = "D:/svn/ks/trunk/ks-api/ks-enroll-api/src/main/java";
84 private static final String LUM_DIRECTORY = "D:/svn/ks/trunk/ks-api/ks-lum-api/src/main/java";
85 private static final String RICE_CORE_API_DIRECTORY = "D:/svn/rice/rice-2.2.0-M3/core/api/src/main/java";
86 private static final String RICE_KIM_API_DIRECTORY = "D:/svn/rice/rice-2.2.0-M3/kim/kim-api/src/main/java";
87 private static final String TEST_SOURCE_DIRECTORY =
88 "src/test/java/org/kuali/student/contract/model/test/source";
89 private static final String TARGET_GENERATED_SOURCES = "target/generated-sources";
90 private static final String STANDALONE_MAIN_DIRECTORY = "D:/svn/ks/ks-standalone-admin-app/src/main";
91
92 public static void main(String[] args) {
93 log.info("execute");
94 List<String> srcDirs = new ArrayList<String>();
95 srcDirs.add(COMMON_DIRECTORY);
96 srcDirs.add(CORE_DIRECTORY);
97 srcDirs.add(LUM_DIRECTORY);
98 srcDirs.add(ENROLL_DIRECTORY);
99
100
101 KSCreateAdminUiMojo instance = new KSCreateAdminUiMojo();
102 Map pluginContext = new HashMap();
103 MavenProject project = new MavenProject();
104 pluginContext.put("project", project);
105 instance.setPluginContext(pluginContext);
106 instance.setSourceDirs(srcDirs);
107 instance.setTargetDir(STANDALONE_MAIN_DIRECTORY);
108 try {
109 instance.execute();
110
111 } catch (MojoExecutionException ex) {
112 throw new RuntimeException(ex);
113 } catch (MojoFailureException ex) {
114 throw new RuntimeException(ex);
115 }
116 }
117 }