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.MockImplWriter;
26
27
28
29
30
31 public class MockImplWriterRun {
32
33 public MockImplWriterRun() {
34 }
35 private static final String CORE_DIRECTORY =
36 "C:/svn/student/ks-core/ks-core-api/src/main/java";
37 private static final String ENROLL13_DIRECTORY =
38 "C:/svn/ks-1.3/ks-enroll/ks-enroll-api/src/main/java";
39 private static final String ENROLL13_SERVICES_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(ENROLL13_SERVICES_DIRECTORY);
50
51
52
53
54 ServiceContractModel instance = new ServiceContractModelQDoxLoader(srcDirs);
55 return new ServiceContractModelCache(instance);
56 }
57
58 private static void validate(ServiceContractModel model) {
59 Collection<String> errors =
60 new ServiceContractModelValidator(model).validate();
61 if (!errors.isEmpty()) {
62 StringBuilder buf = new StringBuilder();
63 buf.append(errors.size()).append(" errors found while validating the data.");
64 int cnt = 0;
65 for (String msg : errors) {
66 cnt++;
67 buf.append("\n");
68 buf.append("*error*").append(cnt).append(":").append(msg);
69 }
70
71 throw new IllegalArgumentException(buf.toString());
72 }
73 }
74
75 public static void main(String[] args) {
76 ServiceContractModel model = getModel();
77 validate(model);
78
79
80
81
82
83
84
85
86
87
88
89
90 String targetDir = "target/gen-src";
91
92 boolean isR1 = false;
93 MockImplWriter instance =
94 new MockImplWriter(model,
95 targetDir,
96 MockImplWriter.ROOT_PACKAGE,
97
98 null,
99 isR1);
100 instance.write();
101
102 }
103 }