001 /** 002 * Copyright 2004-2013 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.opensource.org/licenses/ecl2.php 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 023 import org.apache.maven.plugin.MojoExecutionException; 024 import org.apache.maven.plugin.MojoFailureException; 025 import org.apache.maven.project.MavenProject; 026 import org.kuali.student.common.mojo.AbstractKSMojo; 027 import org.kuali.student.contract.model.ServiceContractModel; 028 import org.kuali.student.contract.model.util.ServicesFilterByKeys; 029 import org.slf4j.Logger; 030 import org.slf4j.LoggerFactory; 031 032 /** 033 * 034 * @author nwright 035 * 036 * @goal kscreateadminui 037 * @phase none 038 * @requiresProject true 039 */ 040 public class KSCreateAdminUiMojo extends AbstractKSMojo { 041 042 private static final Logger log = LoggerFactory.getLogger(KSCreateAdminUiMojo.class); 043 044 public KSCreateAdminUiMojo() { 045 } 046 public String targetDir; 047 048 public String getTargetDir() { 049 return targetDir; 050 } 051 052 public void setTargetDir(String targetDir) { 053 this.targetDir = targetDir; 054 } 055 056 @Override 057 public void execute() throws MojoExecutionException, MojoFailureException { 058 ServiceContractModel model = getModel(); 059 validate(model); 060 if (targetDir == null) { 061 targetDir = "target/generated-sources/admin-ui"; 062 } 063 // ServicesFilterKualiStudentOnly filter = new ServicesFilterKualiStudentOnly (); 064 List<String> servKeys = new ArrayList<String>(); 065 servKeys.add("Atp"); 066 // servKeys.add("Type"); 067 // servKeys.add("State"); 068 // servKeys.add("LRC"); 069 servKeys.add("Organization"); 070 ServicesFilterByKeys filter = new ServicesFilterByKeys(servKeys); 071 072 AdminUiWriter instance = 073 new AdminUiWriter(model, 074 targetDir, 075 AdminUiWriter.DEFAULT_ROOT_PACKAGE, 076 // TODO: inject filters as part of the Mojo parameters 077 filter); 078 instance.write(); 079 080 } 081 private static final String CORE_DIRECTORY = "D:/svn/org-fixer/ks-api/ks-core-api/src/main"; 082 // "C:/svn/maven-dictionary-generator/trunk/src/main/java/org/kuali/student/core"; 083 private static final String COMMON_DIRECTORY = "D:/svn/org-fixer/ks-api/ks-common-api/src/main/java"; 084 private static final String ENROLL_DIRECTORY = "D:/svn/org-fixer/ks-api/ks-enroll-api/src/main/java"; 085 private static final String LUM_DIRECTORY = "D:/svn/org-fixer/ks-api/ks-lum-api/src/main/java"; 086 private static final String RICE_CORE_API_DIRECTORY = "D:/svn/rice/rice-2.2.0-M3/core/api/src/main/java"; 087 private static final String RICE_KIM_API_DIRECTORY = "D:/svn/rice/rice-2.2.0-M3/kim/kim-api/src/main/java"; 088 private static final String TEST_SOURCE_DIRECTORY = 089 "src/test/java/org/kuali/student/contract/model/test/source"; 090 private static final String TARGET_GENERATED_SOURCES = "target/generated-sources"; 091 private static final String STANDALONE_MAIN_DIRECTORY = "D:/svn/ks/ks-standalone-admin-app/src/main"; 092 private static final String ORG_FIXER_CORE_UI_MAIN_DIRECTORY = "D:/svn/org-fixer/ks-core/ks-core-ui/src/main"; 093 094 public static void main(String[] args) { 095 log.info("execute"); 096 List<String> srcDirs = new ArrayList<String>(); 097 srcDirs.add(COMMON_DIRECTORY); 098 srcDirs.add(CORE_DIRECTORY); 099 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 }