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.contract.command.run; 017 018 import java.util.ArrayList; 019 import java.util.Collection; 020 import java.util.List; 021 import org.kuali.student.contract.model.ServiceContractModel; 022 import org.kuali.student.contract.model.impl.ServiceContractModelCache; 023 import org.kuali.student.contract.model.impl.ServiceContractModelQDoxLoader; 024 import org.kuali.student.contract.model.validation.ServiceContractModelValidator; 025 import org.kuali.student.contract.writer.service.MockImplWriter; 026 027 /** 028 * 029 * @author nwright 030 */ 031 public class MockImplWriterRun { 032 033 public MockImplWriterRun() { 034 } 035 private static final String CORE_DIRECTORY = 036 "C:/svn/student/ks-core/ks-core-api/src/main/java"; 037 private static final String ENROLL13_DIRECTORY = 038 "C:/svn/ks-1.3/ks-enroll/ks-enroll-api/src/main/java"; 039 private static final String ENROLL13_SERVICES_DIRECTORY = 040 "C:/svn/ks-1.3-services/ks-enroll/ks-enroll-api/src/main/java"; 041 // "C:/svn/maven-dictionary-generator/trunk/src/main/java/org/kuali/student/core"; 042 private static final String COMMON_DIRECTORY = 043 "C:/svn/student/ks-common/ks-common-api/src/main/java"; 044 private static final String LUM_DIRECTORY = 045 "C:/svn/student/ks-lum/ks-lum-api/src/main/java"; 046 047 private static ServiceContractModel getModel() { 048 List<String> srcDirs = new ArrayList(); 049 srcDirs.add(ENROLL13_SERVICES_DIRECTORY); 050 // srcDirs.add(ENROLL13_DIRECTORY); 051 // srcDirs.add(LUM_DIRECTORY); 052 // srcDirs.add(CORE_DIRECTORY); 053 // srcDirs.add(COMMON_DIRECTORY); 054 ServiceContractModel instance = new ServiceContractModelQDoxLoader(srcDirs); 055 return new ServiceContractModelCache(instance); 056 } 057 058 private static void validate(ServiceContractModel model) { 059 Collection<String> errors = 060 new ServiceContractModelValidator(model).validate(); 061 if (!errors.isEmpty()) { 062 StringBuilder buf = new StringBuilder(); 063 buf.append(errors.size()).append(" errors found while validating the data."); 064 int cnt = 0; 065 for (String msg : errors) { 066 cnt++; 067 buf.append("\n"); 068 buf.append("*error*").append(cnt).append(":").append(msg); 069 } 070 071 throw new IllegalArgumentException(buf.toString()); 072 } 073 } 074 075 public static void main(String[] args) { 076 ServiceContractModel model = getModel(); 077 validate(model); 078 // List<String> servicesToProcess = new ArrayList (); 079 // servicesToProcess.add ("atp"); 080 // servicesToProcess.add ("lu"); 081 // servicesToProcess.add ("lo"); 082 // servicesToProcess.add ("organization"); 083 // servicesToProcess.add ("proposal"); 084 //// servicesToProcess.add ("comment"); 085 // servicesToProcess.add ("dictionary"); 086 // servicesToProcess.add ("document"); 087 // servicesToProcess.add ("enumerable"); 088 // servicesToProcess.add ("search"); 089 // ServicesFilter filter = new ServicesFilterByKeys (servicesToProcess); 090 String targetDir = "target/gen-src"; 091 // targetDir = "src/main/java"; 092 boolean isR1 = false; 093 MockImplWriter instance = 094 new MockImplWriter(model, 095 targetDir, 096 MockImplWriter.ROOT_PACKAGE, 097 // MockImplWriter.ENROLLMENT_ROOT_PACKAGE, 098 null, 099 isR1); 100 instance.write(); 101 102 } 103 }