1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.student.contract.command.run;
17
18 import java.util.ArrayList;
19 import java.util.Collection;
20 import java.util.List;
21
22 import org.kuali.student.contract.model.ServiceContractModel;
23 import org.kuali.student.contract.model.impl.ServiceContractModelCache;
24 import org.kuali.student.contract.model.impl.ServiceContractModelQDoxLoader;
25 import org.kuali.student.contract.model.validation.ServiceContractModelValidator;
26 import org.kuali.student.contract.writer.service.PureJavaInfcWriter;
27
28
29
30
31
32 public class PureJavaInterfaceWriterRun
33 {
34
35 public PureJavaInterfaceWriterRun ()
36 {
37 }
38 private static final String CORE_DIRECTORY =
39 "C:/svn/student/ks-core/ks-core-api/src/main/java";
40
41 private static final String COMMON_DIRECTORY =
42 "C:/svn/student/ks-common/ks-common-api/src/main/java";
43 private static final String LUM_DIRECTORY =
44 "C:/svn/student/ks-lum/ks-lum-api/src/main/java";
45
46 private static ServiceContractModel getModel ()
47 {
48 List<String> srcDirs = new ArrayList ();
49 srcDirs.add (CORE_DIRECTORY);
50 srcDirs.add (COMMON_DIRECTORY);
51 srcDirs.add (LUM_DIRECTORY);
52 ServiceContractModel instance = new ServiceContractModelQDoxLoader (srcDirs);
53 return new ServiceContractModelCache (instance);
54 }
55
56 private static void validate (ServiceContractModel model)
57 {
58 Collection<String> errors =
59 new ServiceContractModelValidator (model).validate ();
60 if (errors.size () > 0)
61 {
62 StringBuffer buf = new StringBuffer ();
63 buf.append (errors.size () + " errors found while validating the data.");
64 int cnt = 0;
65 for (String msg : errors)
66 {
67 cnt ++;
68 buf.append ("\n");
69 buf.append ("*error*" + cnt + ":" + msg);
70 }
71
72 throw new IllegalArgumentException (buf.toString ());
73 }
74 }
75
76 public static void main (String[] args)
77 {
78 ServiceContractModel model = getModel ();
79 validate (model);
80
81
82
83
84
85
86
87
88
89
90
91
92 String targetDir = "target/gen-src";
93
94 PureJavaInfcWriter instance =
95 new PureJavaInfcWriter (model,
96 targetDir,
97 PureJavaInfcWriter.DEFAULT_ROOT_PACKAGE,
98 null);
99 instance.write ();
100
101 }
102 }