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  
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.impl.ServiceContractModelPescXsdLoader;
29  import org.kuali.student.contract.model.util.ServicesFilterByKeys;
30  import org.slf4j.Logger;
31  import org.slf4j.LoggerFactory;
32  
33  /**
34   *
35   * @author nwright
36   *
37   * @goal kscreateremoteimpl
38   * @phase none
39   * @requiresProject true
40   */
41  public class KSCreateRemoteImplMojo extends AbstractKSMojo {
42      
43      private static Logger log = LoggerFactory.getLogger(KSCreateRemoteImplMojo.class);
44  
45      public KSCreateRemoteImplMojo() {
46      }
47      public String targetDir;
48  
49      public String getTargetDir() {
50          return targetDir;
51      }
52  
53      public void setTargetDir(String targetDir) {
54          this.targetDir = targetDir;
55      }
56  
57      @Override
58      public void execute() throws MojoExecutionException, MojoFailureException {
59  
60          ServiceContractModel model = getModel();
61          validate(model);
62          if (targetDir == null) {
63              String targetDir = "target/generated-sources/remote-impl";
64          }
65          List<String> servKeys = new ArrayList<String>();
66          servKeys.add("AcademicCalendar");
67  //        servKeys.add("AcademicRecord");
68          servKeys.add("Appointment");
69  //        servKeys.add("Atp");
70  //        servKeys.add("BatchJobResult");
71          servKeys.add("Clu");
72          servKeys.add("Comment");
73          servKeys.add("CourseOffering");
74          servKeys.add("CourseOfferingSet");
75  //        servKeys.add("CourseRegistration");
76          servKeys.add("Course");
77  //        servKeys.add("CourseWaitlist");
78  //        servKeys.add("DataDictionary");
79          servKeys.add("Document");
80          servKeys.add("EnumerationManagement");
81          servKeys.add("Exemption");
82  //        servKeys.add("Fee");
83  //        servKeys.add("Grading");
84          servKeys.add("Hold");
85  //        servKeys.add("LRC");
86          servKeys.add("LearningObjective");
87  //        servKeys.add("LearningResultRecord");
88  //        servKeys.add("LprRoster");
89          servKeys.add("Lpr");
90          servKeys.add("Lui");
91          servKeys.add("Message");
92          servKeys.add("Organization");
93          servKeys.add("Population");
94          servKeys.add("Process");
95          servKeys.add("Program");
96          servKeys.add("Proposal");
97          servKeys.add("Room");
98          servKeys.add("Scheduling");
99  //        servKeys.add("Search");
100 //        servKeys.add("State");
101 //        servKeys.add("Statement");
102 //        servKeys.add("Type");
103 //        servKeys.add("VersionManagement");
104 
105 //        servKeys.add("Atp");
106 //        servKeys.add("Type");
107 //        servKeys.add("State");
108 //        servKeys.add("LRC");
109 //        servKeys.add("RICE.Permission");
110 //        servKeys.add("RICE.Role");
111         ServicesFilterByKeys filter = new ServicesFilterByKeys(servKeys);
112         RemoteImplWriter instance =
113                 new RemoteImplWriter(model,
114                 targetDir,
115                 RemoteImplWriter.DEFAULT_ROOT_PACKAGE,
116                 // TODO: inject filters as part of the Mojo parameters
117                 filter);
118         instance.write();
119 
120     }
121     private static final String CORE_DIRECTORY = "D:/svn/ks/trunk/ks-api/ks-core-api/src/main";
122     // "C:/svn/maven-dictionary-generator/trunk/src/main/java/org/kuali/student/core";
123     private static final String COMMON_DIRECTORY = "D:/svn/ks/trunk/ks-api/ks-common-api/src/main/java";
124     private static final String ENROLL_DIRECTORY = "D:/svn/ks/trunk/ks-api/ks-enroll-api/src/main/java";
125     private static final String LUM_DIRECTORY = "D:/svn/ks/trunk/ks-api/ks-lum-api/src/main/java";
126     private static final String RICE_CORE_API_DIRECTORY = "D:/svn/rice/rice-2.2.0-M3/core/api/src/main/java";
127     private static final String RICE_KIM_API_DIRECTORY = "D:/svn/rice/rice-2.2.0-M3/kim/kim-api/src/main/java";
128     private static final String TEST_SOURCE_DIRECTORY =
129             "src/test/java/org/kuali/student/contract/model/test/source";
130     private static final String TARGET_GENERATED_SOURCES = "target/generated-sources";
131     private static final String STANDALONE_DIRECTORY = "D:/svn/ks/ks-standalone-admin-app/src";
132 
133     public static void main(String[] args) {
134         log.info("execute");
135         List<String> srcDirs = new ArrayList<String>();
136         srcDirs.add(COMMON_DIRECTORY);
137         srcDirs.add(CORE_DIRECTORY);
138         srcDirs.add(LUM_DIRECTORY);
139         srcDirs.add(ENROLL_DIRECTORY);
140         srcDirs.add(RICE_KIM_API_DIRECTORY);
141 //        srcDirs.add(RICE_CORE_API_DIRECTORY);
142         KSCreateRemoteImplMojo instance = new KSCreateRemoteImplMojo();
143         Map pluginContext = new HashMap();
144         MavenProject project = new MavenProject();
145         pluginContext.put("project", project);
146         instance.setPluginContext(pluginContext);
147         instance.setSourceDirs(srcDirs);
148         instance.setTargetDir(STANDALONE_DIRECTORY);
149         try {
150             instance.execute();
151         } catch (MojoExecutionException ex) {
152             throw new RuntimeException(ex);
153         } catch (MojoFailureException ex) {
154             throw new RuntimeException(ex);
155         }
156     }
157 }