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 import org.kuali.student.contract.model.ServiceContractModel;
22 import org.kuali.student.contract.model.impl.ServiceContractModelCache;
23 import org.kuali.student.contract.model.impl.ServiceContractModelQDoxLoader;
24 import org.kuali.student.contract.model.validation.ServiceContractModelValidator;
25 import org.kuali.student.contract.writer.service.EachMethodServiceWriter;
26
27
28
29
30
31 public class EachMethodServiceWriterRun {
32
33 public EachMethodServiceWriterRun() {
34 }
35
36 public static final String DEFAULT_ROOT_PACKAGE = "org.kuali.student.enrollment";
37 private static final String CORE_DIRECTORY =
38 "C:/svn/student/ks-core/ks-core-api/src/main/java";
39 private static final String ENROLL_DIRECTORY =
40 "C:/svn/ks-1.3-services/ks-enroll/ks-enroll-api/src/main/java";
41
42 private static final String COMMON_DIRECTORY =
43 "C:/svn/student/ks-common/ks-common-api/src/main/java";
44 private static final String LUM_DIRECTORY =
45 "C:/svn/student/ks-lum/ks-lum-api/src/main/java";
46
47 private static ServiceContractModel getModel() {
48 List<String> srcDirs = new ArrayList();
49 srcDirs.add(ENROLL_DIRECTORY);
50 ServiceContractModel instance = new ServiceContractModelQDoxLoader(srcDirs);
51 return new ServiceContractModelCache(instance);
52 }
53
54 private static void validate(ServiceContractModel model) {
55 Collection<String> errors =
56 new ServiceContractModelValidator(model).validate();
57 if (!errors.isEmpty()) {
58 StringBuilder buf = new StringBuilder();
59 buf.append(errors.size()).append(" errors found while validating the data.");
60 int cnt = 0;
61 for (String msg : errors) {
62 cnt++;
63 buf.append("\n");
64 buf.append("*error*").append(cnt).append(":").append(msg);
65 }
66
67 throw new IllegalArgumentException(buf.toString());
68 }
69 }
70
71 public static void main(String[] args) {
72 ServiceContractModel model = getModel();
73 validate(model);
74
75
76
77
78
79
80
81
82
83
84
85
86 String targetDir = "target/gen-src";
87
88 EachMethodServiceWriter instance =
89 new EachMethodServiceWriter(model,
90 targetDir,
91 DEFAULT_ROOT_PACKAGE,
92 null);
93 instance.write();
94
95 }
96 }