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  import org.apache.maven.plugin.MojoExecutionException;
23  import org.apache.maven.plugin.MojoFailureException;
24  import org.apache.maven.project.MavenProject;
25  import org.kuali.student.common.mojo.AbstractKSMojo;
26  import org.kuali.student.contract.model.ServiceContractModel;
27  import org.kuali.student.contract.model.util.ServicesFilterByKeys;
28  
29  /**
30   *
31   * @author nwright
32   *
33   * @goal kscreateadminui
34   * @phase none
35   * @requiresProject true
36   */
37  public class KSCreateAdminUiMojo extends AbstractKSMojo {
38  
39      public KSCreateAdminUiMojo() {
40      }
41      public String targetDir;
42  
43      public String getTargetDir() {
44          return targetDir;
45      }
46  
47      public void setTargetDir(String targetDir) {
48          this.targetDir = targetDir;
49      }
50  
51      @Override
52      public void execute() throws MojoExecutionException, MojoFailureException {
53          ServiceContractModel model = getModel();
54          validate(model);
55          if (targetDir == null) {
56              targetDir = "target/generated-sources/admin-ui";
57          }
58  //        ServicesFilterKualiStudentOnly filter = new ServicesFilterKualiStudentOnly ();
59          List<String> servKeys = new ArrayList<String>();
60          servKeys.add("Atp");
61          servKeys.add("Type");
62          servKeys.add("State");
63          servKeys.add("LRC");
64          ServicesFilterByKeys filter = new ServicesFilterByKeys(servKeys);
65  
66          AdminUiWriter instance =
67                  new AdminUiWriter(model,
68                  targetDir,
69                  AdminUiWriter.DEFAULT_ROOT_PACKAGE,
70                  // TODO: inject filters as part of the Mojo parameters
71                  filter);
72          instance.write();
73  
74      }
75      private static final String CORE_DIRECTORY = "D:/svn/ks/trunk/ks-api/ks-core-api/src/main";
76      // "C:/svn/maven-dictionary-generator/trunk/src/main/java/org/kuali/student/core";
77      private static final String COMMON_DIRECTORY = "D:/svn/ks/trunk/ks-api/ks-common-api/src/main/java";
78      private static final String ENROLL_DIRECTORY = "D:/svn/ks/trunk/ks-api/ks-enroll-api/src/main/java";
79      private static final String LUM_DIRECTORY = "D:/svn/ks/trunk/ks-api/ks-lum-api/src/main/java";
80      private static final String RICE_CORE_API_DIRECTORY = "D:/svn/rice/rice-2.2.0-M3/core/api/src/main/java";
81      private static final String RICE_KIM_API_DIRECTORY = "D:/svn/rice/rice-2.2.0-M3/kim/kim-api/src/main/java";
82      private static final String TEST_SOURCE_DIRECTORY =
83              "src/test/java/org/kuali/student/contract/model/test/source";
84      private static final String TARGET_GENERATED_SOURCES = "target/generated-sources";
85      private static final String STANDALONE_MAIN_DIRECTORY = "D:/svn/ks/ks-standalone-admin-app/src/main";
86  
87      public static void main(String[] args) {
88          System.out.println("execute");
89          List<String> srcDirs = new ArrayList<String>();
90          srcDirs.add(COMMON_DIRECTORY);
91          srcDirs.add(CORE_DIRECTORY);
92          srcDirs.add(LUM_DIRECTORY);
93          srcDirs.add(ENROLL_DIRECTORY);
94          srcDirs.add(RICE_KIM_API_DIRECTORY);
95  //        srcDirs.add(RICE_CORE_API_DIRECTORY);
96          KSCreateAdminUiMojo instance = new KSCreateAdminUiMojo();
97          Map pluginContext = new HashMap();
98          MavenProject project = new MavenProject();
99          pluginContext.put("project", project);
100         instance.setPluginContext(pluginContext);
101         instance.setSourceDirs(srcDirs);
102         instance.setTargetDir(STANDALONE_MAIN_DIRECTORY);
103         try {
104             instance.execute();
105             //        assertTrue(new File(instance.getOutputDirectory() + "/" + "ks-LprInfo-dictionary.xml").exists());  
106         } catch (MojoExecutionException ex) {
107             throw new RuntimeException(ex);
108         } catch (MojoFailureException ex) {
109             throw new RuntimeException(ex);
110         }
111     }
112 }