1
2
3
4
5 package org.kuali.rice.krms.impl.repository.mock;
6
7 import java.util.HashMap;
8 import java.util.LinkedHashSet;
9 import java.util.Map;
10 import java.util.Set;
11 import org.kuali.rice.krms.api.repository.term.TermRepositoryService;
12 import org.kuali.rice.krms.api.repository.term.TermResolverDefinition;
13 import org.kuali.rice.krms.api.repository.term.TermSpecificationDefinition;
14
15
16
17
18
19 public class KrmsTermResolverLoader {
20
21 private TermRepositoryService termRepositoryService = null;
22
23 public TermRepositoryService getTermRepositoryService() {
24 return termRepositoryService;
25 }
26
27 public void setTermRepositoryService(TermRepositoryService termRepositoryService) {
28 this.termRepositoryService = termRepositoryService;
29 }
30
31 public void loadTermResolver(String id,
32 String namespace,
33 String name,
34 String typeId,
35 String outputId,
36 String prereqId1,
37 String prereqId2,
38 String prereqId3) {
39 TermSpecificationDefinition.Builder output =
40 TermSpecificationDefinition.Builder.create(this.getTermRepositoryService().getTermSpecificationById(outputId));
41 Set<TermSpecificationDefinition.Builder> prerequisites =
42 new LinkedHashSet<TermSpecificationDefinition.Builder>();
43 if (prereqId1 != null && !prereqId1.isEmpty()) {
44 prerequisites.add(TermSpecificationDefinition.Builder.create(this.getTermRepositoryService().getTermSpecificationById(prereqId1)));
45 }
46 if (prereqId2 != null && !prereqId2.isEmpty()) {
47 prerequisites.add(TermSpecificationDefinition.Builder.create(this.getTermRepositoryService().getTermSpecificationById(prereqId2)));
48 }
49 if (prereqId3 != null && !prereqId3.isEmpty()) {
50 prerequisites.add(TermSpecificationDefinition.Builder.create(this.getTermRepositoryService().getTermSpecificationById(prereqId3)));
51 }
52 Map<String, String> attributes = new HashMap<String, String>();
53
54 Set<String> parameterNames = new LinkedHashSet<String>();
55
56
57
58
59
60
61
62
63 TermResolverDefinition.Builder bldr = TermResolverDefinition.Builder.create(id,
64 namespace,
65 name,
66 typeId,
67 output,
68 prerequisites,
69 attributes,
70 parameterNames);
71 bldr.setActive(true);
72 this.getTermRepositoryService().createTermResolver(bldr.build());
73 }
74
75 public void load(){
76 loadTermResolver("10000", "KS-SYS", "CompletedCourse", "10000", "10000", "", "", "");
77 loadTermResolver("10001", "KS-SYS", "CompletedCourses", "10000", "10001", "", "", "");
78 loadTermResolver("10002", "KS-SYS", "NumberOfCompletedCourses", "10000", "10002", "", "", "");
79 loadTermResolver("10003", "KS-SYS", "NumberOfCreditsFromCompletedCourses", "10000", "10003", "", "", "");
80 loadTermResolver("10004", "KS-SYS", "EnrolledCourses", "10000", "10004", "", "", "");
81 loadTermResolver("10005", "KS-SYS", "GPAForCourses", "10000", "10005", "", "", "");
82 loadTermResolver("10006", "KS-SYS", "GradeTypeForCourses", "10000", "10006", "", "", "");
83 loadTermResolver("10007", "KS-SYS", "NumberOfCredits", "10000", "10007", "", "", "");
84 loadTermResolver("10008", "KS-SYS", "NumberOfCreditsFromOrganization", "10000", "10008", "", "", "");
85 loadTermResolver("10009", "KS-SYS", "AdminOrganizationPermissionRequired", "10000", "10009", "", "", "");
86 loadTermResolver("10010", "KS-SYS", "ScoreOnTest", "10000", "10010", "", "", "");
87 loadTermResolver("10011", "KS-SYS", "AdmittedToProgram", "10000", "10011", "", "", "");
88 loadTermResolver("10012", "KS-SYS", "AdmittedToProgramLimitCoursesInOrgForDuration", "10000", "10012", "", "", "");
89 loadTermResolver("10013", "KS-SYS", "FreeFormText", "10000", "10013", "", "", "");
90 }
91
92
93 }