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.jpa.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.ServicesFilter;
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 ks-create-jpa-impl
38   *  @phase site
39   *  @requiresProject true
40   */
41  public class KSCreateJpaImplMojo extends AbstractKSMojo {
42  
43      private static final Logger log = LoggerFactory.getLogger(KSCreateJpaImplMojo.class);
44      
45      public KSCreateJpaImplMojo() {
46      }
47   
48      private String targetDir;
49  
50      public String getTargetDir() {
51          return targetDir;
52      }
53  
54      public void setTargetDir(String targetDir) {
55          this.targetDir = targetDir;
56      }
57      
58      
59      
60      @Override
61  	public void execute() throws MojoExecutionException, MojoFailureException {
62          ServiceContractModel model = getModel();
63          validate(model);
64          if (targetDir == null) {
65              targetDir = "target/generated-jpa-impls";
66          }
67          List<String> servKeys = new ArrayList<String>();
68  //        servKeys.add ("Atp");
69  //        ServicesFilter filter = new ServicesFilterByKeys (servKeys);
70          ServicesFilter filter = null;
71          boolean isR1 = false;
72          JpaImplWriter instance =
73                  new JpaImplWriter(model,
74                  targetDir,
75                  JpaImplWriter.ROOT_PACKAGE,
76                  filter,
77                  isR1);
78          instance.write();
79  
80      }
81      
82      
83      
84      private static final String CORE_DIRECTORY = "D:/svn/ks/trunk/ks-api/ks-core-api/src/main";
85      // "C:/svn/maven-dictionary-generator/trunk/src/main/java/org/kuali/student/core";
86      private static final String COMMON_DIRECTORY = "D:/svn/ks/trunk/ks-api/ks-common-api/src/main/java";
87      private static final String ENROLL_DIRECTORY = "D:/svn/ks/trunk/ks-api/ks-enroll-api/src/main/java";
88      private static final String LUM_DIRECTORY = "D:/svn/ks/trunk/ks-api/ks-lum-api/src/main/java";
89      private static final String RICE_CORE_API_DIRECTORY = "D:/svn/rice/rice-2.2.0/core/api/src/main/java";
90      private static final String RICE_KIM_API_DIRECTORY = "D:/svn/rice/rice-2.2.0/kim/kim-api/src/main/java";
91      private static final String RICE_KRMS_API_DIRECTORY = "D:/svn/rice/rice-2.2.0/krms/api/src/main/java";
92      private static final String TEST_SOURCE_DIRECTORY =
93              "src/test/java/org/kuali/student/contract/model/test/source";
94      private static final String TARGET_GENERATED_SOURCES = "target/generated-sources";
95      private static final String STANDALONE_MAIN_DIRECTORY = "D:/svn/ks/ks-standalone-admin-app/src/main";
96      private static final String SERVICES_ENROLL_IMPL = "D:/svn/ks/services/ks-enroll/ks-enroll-impl/src/main/java";
97      private static final String CM_CORE_API = "D:/svn/ks/CM-2.0/ks-api/ks-core-api/src/main/java";
98      private static final String TRUNK_CORE_IMPL = "D:/svn/ks/trunk/ks-core/ks-core-impl/src/main/java";
99      private static final String TRUNK_ENROLL_IMPL = "D:/svn/ks/trunk/ks-enroll/ks-enroll-impl/src/main/java";
100     private static final String TRUNK_ENROLL_IMPL_KRMS_API = "D:/svn/ks/trunk/ks-enroll/ks-enroll-impl/src/main/java/org/kuali/rice/krms/api";
101                                                    
102 
103     public static void main(String[] args) {
104         log.info("execute");
105         List<String> srcDirs = new ArrayList<String>();
106         srcDirs.add(COMMON_DIRECTORY);
107         srcDirs.add(CORE_DIRECTORY);
108         srcDirs.add(LUM_DIRECTORY);
109         srcDirs.add(ENROLL_DIRECTORY);
110 //        srcDirs.add(RICE_KIM_API_DIRECTORY);
111 //        srcDirs.add(RICE_CORE_API_DIRECTORY);
112 //        srcDirs.add(RICE_KRMS_API_DIRECTORY);
113 //        srcDirs.add(TRUNK_ENROLL_IMPL_KRMS_API);
114         KSCreateJpaImplMojo instance = new KSCreateJpaImplMojo();
115         Map pluginContext = new HashMap();
116         MavenProject project = new MavenProject();
117         pluginContext.put("project", project);
118         instance.setPluginContext(pluginContext);
119         instance.setSourceDirs(srcDirs);
120 //        instance.setTargetDir(SERVICES_ENROLL_IMPL);
121 //        instance.setTargetDir(CM_CORE_API);
122         instance.setTargetDir(TRUNK_ENROLL_IMPL);
123         try {
124             instance.execute();
125             //        assertTrue(new File(instance.getOutputDirectory() + "/" + "ks-LprInfo-dictionary.xml").exists());  
126         } catch (MojoExecutionException ex) {
127             throw new RuntimeException(ex);
128         } catch (MojoFailureException ex) {
129             throw new RuntimeException(ex);
130         }
131     }
132 }