View Javadoc
1   /**
2    * Copyright 2004-2014 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.opensource.org/licenses/ecl2.php
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          servKeys.add("Organization");
70          ServicesFilterByKeys filter = new ServicesFilterByKeys(servKeys);
71  
72          AdminUiWriter instance =
73                  new AdminUiWriter(model,
74                  targetDir,
75                  AdminUiWriter.DEFAULT_ROOT_PACKAGE,
76                  // TODO: inject filters as part of the Mojo parameters
77                  filter);
78          instance.write();
79  
80      }
81      private static final String CORE_DIRECTORY = "D:/svn/org-fixer/ks-api/ks-core-api/src/main";
82      // "C:/svn/maven-dictionary-generator/trunk/src/main/java/org/kuali/student/core";
83      private static final String COMMON_DIRECTORY = "D:/svn/org-fixer/ks-api/ks-common-api/src/main/java";
84      private static final String ENROLL_DIRECTORY = "D:/svn/org-fixer/ks-api/ks-enroll-api/src/main/java";
85      private static final String LUM_DIRECTORY = "D:/svn/org-fixer/ks-api/ks-lum-api/src/main/java";
86      private static final String RICE_CORE_API_DIRECTORY = "D:/svn/rice/rice-2.2.0-M3/core/api/src/main/java";
87      private static final String RICE_KIM_API_DIRECTORY = "D:/svn/rice/rice-2.2.0-M3/kim/kim-api/src/main/java";
88      private static final String TEST_SOURCE_DIRECTORY =
89              "src/test/java/org/kuali/student/contract/model/test/source";
90      private static final String TARGET_GENERATED_SOURCES = "target/generated-sources";
91      private static final String STANDALONE_MAIN_DIRECTORY = "D:/svn/ks/ks-standalone-admin-app/src/main";
92      private static final String ORG_FIXER_CORE_UI_MAIN_DIRECTORY = "D:/svn/org-fixer/ks-core/ks-core-ui/src/main";
93  
94      public static void main(String[] args) {
95          log.info("execute");
96          List<String> srcDirs = new ArrayList<String>();
97          srcDirs.add(COMMON_DIRECTORY);
98          srcDirs.add(CORE_DIRECTORY);
99          srcDirs.add(LUM_DIRECTORY);
100         srcDirs.add(ENROLL_DIRECTORY);
101 //        srcDirs.add(RICE_KIM_API_DIRECTORY);
102 //        srcDirs.add(RICE_CORE_API_DIRECTORY);
103         KSCreateAdminUiMojo instance = new KSCreateAdminUiMojo();
104         Map pluginContext = new HashMap();
105         MavenProject project = new MavenProject();
106         pluginContext.put("project", project);
107         instance.setPluginContext(pluginContext);
108         instance.setSourceDirs(srcDirs);
109         instance.setTargetDir(ORG_FIXER_CORE_UI_MAIN_DIRECTORY);
110         try {
111             instance.execute();
112             //        assertTrue(new File(instance.getOutputDirectory() + "/" + "ks-LprInfo-dictionary.xml").exists());  
113         } catch (MojoExecutionException ex) {
114             throw new RuntimeException(ex);
115         } catch (MojoFailureException ex) {
116             throw new RuntimeException(ex);
117         }
118     }
119 }