View Javadoc

1   /*
2    * Copyright 2009 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may	obtain a copy of the License at
7    *
8    * 	http://www.osedu.org/licenses/ECL-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
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   * @author nwright
35   *
36   * @goal kscreateadminui
37   * @phase none
38   * @requiresProject true
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  //        ServicesFilterKualiStudentOnly filter = new ServicesFilterKualiStudentOnly ();
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                  // TODO: inject filters as part of the Mojo parameters
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      // "C:/svn/maven-dictionary-generator/trunk/src/main/java/org/kuali/student/core";
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  //        srcDirs.add(RICE_KIM_API_DIRECTORY);
100 //        srcDirs.add(RICE_CORE_API_DIRECTORY);
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             //        assertTrue(new File(instance.getOutputDirectory() + "/" + "ks-LprInfo-dictionary.xml").exists());  
111         } catch (MojoExecutionException ex) {
112             throw new RuntimeException(ex);
113         } catch (MojoFailureException ex) {
114             throw new RuntimeException(ex);
115         }
116     }
117 }