001 /* 002 * Copyright 2009 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.osedu.org/licenses/ECL-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package org.kuali.student.admin.ui.mojo; 017 018 import java.util.ArrayList; 019 import java.util.HashMap; 020 import java.util.List; 021 import java.util.Map; 022 import org.apache.maven.plugin.MojoExecutionException; 023 import org.apache.maven.plugin.MojoFailureException; 024 import org.apache.maven.project.MavenProject; 025 import org.kuali.student.common.mojo.AbstractKSMojo; 026 import org.kuali.student.contract.model.ServiceContractModel; 027 import org.kuali.student.contract.model.util.ServicesFilterByKeys; 028 029 /** 030 * 031 * @author nwright 032 * 033 * @goal kscreateadminui 034 * @phase none 035 * @requiresProject true 036 */ 037 public class KSCreateAdminUiMojo extends AbstractKSMojo { 038 039 public KSCreateAdminUiMojo() { 040 } 041 public String targetDir; 042 043 public String getTargetDir() { 044 return targetDir; 045 } 046 047 public void setTargetDir(String targetDir) { 048 this.targetDir = targetDir; 049 } 050 051 @Override 052 public void execute() throws MojoExecutionException, MojoFailureException { 053 ServiceContractModel model = getModel(); 054 validate(model); 055 if (targetDir == null) { 056 targetDir = "target/generated-sources/admin-ui"; 057 } 058 // ServicesFilterKualiStudentOnly filter = new ServicesFilterKualiStudentOnly (); 059 List<String> servKeys = new ArrayList<String>(); 060 servKeys.add("Atp"); 061 servKeys.add("Type"); 062 servKeys.add("State"); 063 servKeys.add("LRC"); 064 ServicesFilterByKeys filter = new ServicesFilterByKeys(servKeys); 065 066 AdminUiWriter instance = 067 new AdminUiWriter(model, 068 targetDir, 069 AdminUiWriter.DEFAULT_ROOT_PACKAGE, 070 // TODO: inject filters as part of the Mojo parameters 071 filter); 072 instance.write(); 073 074 } 075 private static final String CORE_DIRECTORY = "D:/svn/ks/trunk/ks-api/ks-core-api/src/main"; 076 // "C:/svn/maven-dictionary-generator/trunk/src/main/java/org/kuali/student/core"; 077 private static final String COMMON_DIRECTORY = "D:/svn/ks/trunk/ks-api/ks-common-api/src/main/java"; 078 private static final String ENROLL_DIRECTORY = "D:/svn/ks/trunk/ks-api/ks-enroll-api/src/main/java"; 079 private static final String LUM_DIRECTORY = "D:/svn/ks/trunk/ks-api/ks-lum-api/src/main/java"; 080 private static final String RICE_CORE_API_DIRECTORY = "D:/svn/rice/rice-2.2.0-M3/core/api/src/main/java"; 081 private static final String RICE_KIM_API_DIRECTORY = "D:/svn/rice/rice-2.2.0-M3/kim/kim-api/src/main/java"; 082 private static final String TEST_SOURCE_DIRECTORY = 083 "src/test/java/org/kuali/student/contract/model/test/source"; 084 private static final String TARGET_GENERATED_SOURCES = "target/generated-sources"; 085 private static final String STANDALONE_MAIN_DIRECTORY = "D:/svn/ks/ks-standalone-admin-app/src/main"; 086 087 public static void main(String[] args) { 088 System.out.println("execute"); 089 List<String> srcDirs = new ArrayList<String>(); 090 srcDirs.add(COMMON_DIRECTORY); 091 srcDirs.add(CORE_DIRECTORY); 092 srcDirs.add(LUM_DIRECTORY); 093 srcDirs.add(ENROLL_DIRECTORY); 094 srcDirs.add(RICE_KIM_API_DIRECTORY); 095 // srcDirs.add(RICE_CORE_API_DIRECTORY); 096 KSCreateAdminUiMojo instance = new KSCreateAdminUiMojo(); 097 Map pluginContext = new HashMap(); 098 MavenProject project = new MavenProject(); 099 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 }