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.remote.impl.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 kscreateremoteimpl
34   * @phase none
35   * @requiresProject true
36   */
37  public class KSCreateRemoteImplMojo extends AbstractKSMojo {
38  
39      public KSCreateRemoteImplMojo() {
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  
54          ServiceContractModel model = getModel();
55          validate(model);
56          if (targetDir == null) {
57              String targetDir = "target/generated-sources/remote-impl";
58          }
59          List<String> servKeys = new ArrayList<String>();
60          servKeys.add("Atp");
61          servKeys.add("Type");
62          servKeys.add("State");
63          servKeys.add("LRC");
64          servKeys.add("RICE.Permission");
65          servKeys.add("RICE.Role");
66          ServicesFilterByKeys filter = new ServicesFilterByKeys(servKeys);
67          RemoteImplWriter instance =
68                  new RemoteImplWriter(model,
69                  targetDir,
70                  RemoteImplWriter.DEFAULT_ROOT_PACKAGE,
71                  // TODO: inject filters as part of the Mojo parameters
72                  filter);
73          instance.write();
74  
75      }
76      private static final String CORE_DIRECTORY = "D:/svn/ks/trunk/ks-api/ks-core-api/src/main";
77      // "C:/svn/maven-dictionary-generator/trunk/src/main/java/org/kuali/student/core";
78      private static final String COMMON_DIRECTORY = "D:/svn/ks/trunk/ks-api/ks-common-api/src/main/java";
79      private static final String ENROLL_DIRECTORY = "D:/svn/ks/trunk/ks-api/ks-enroll-api/src/main/java";
80      private static final String LUM_DIRECTORY = "D:/svn/ks/trunk/ks-api/ks-lum-api/src/main/java";
81      private static final String RICE_CORE_API_DIRECTORY = "D:/svn/rice/rice-2.2.0-M3/core/api/src/main/java";
82      private static final String RICE_KIM_API_DIRECTORY = "D:/svn/rice/rice-2.2.0-M3/kim/kim-api/src/main/java";
83      private static final String TEST_SOURCE_DIRECTORY =
84              "src/test/java/org/kuali/student/contract/model/test/source";
85      private static final String TARGET_GENERATED_SOURCES = "target/generated-sources";
86      private static final String STANDALONE_DIRECTORY = "D:/svn/ks/ks-standalone-admin-app/src";
87  
88      public static void main(String[] args) {
89          System.out.println("execute");
90          List<String> srcDirs = new ArrayList<String>();
91          srcDirs.add(COMMON_DIRECTORY);
92          srcDirs.add(CORE_DIRECTORY);
93          srcDirs.add(LUM_DIRECTORY);
94          srcDirs.add(ENROLL_DIRECTORY);
95          srcDirs.add(RICE_KIM_API_DIRECTORY);
96  //        srcDirs.add(RICE_CORE_API_DIRECTORY);
97          KSCreateRemoteImplMojo instance = new KSCreateRemoteImplMojo();
98          Map pluginContext = new HashMap();
99          MavenProject project = new MavenProject();
100         pluginContext.put("project", project);
101         instance.setPluginContext(pluginContext);
102         instance.setSourceDirs(srcDirs);
103         instance.setTargetDir(STANDALONE_DIRECTORY);
104         try {
105             instance.execute();
106         } catch (MojoExecutionException ex) {
107             throw new RuntimeException(ex);
108         } catch (MojoFailureException ex) {
109             throw new RuntimeException(ex);
110         }
111     }
112 }