001 /* 002 * To change this template, choose Tools | Templates 003 * and open the template in the editor. 004 */ 005 package org.kuali.rice.krms.impl.repository.mock; 006 007 import java.util.HashMap; 008 import java.util.LinkedHashSet; 009 import java.util.Map; 010 import java.util.Set; 011 import org.kuali.rice.krms.api.repository.term.TermRepositoryService; 012 import org.kuali.rice.krms.api.repository.term.TermResolverDefinition; 013 import org.kuali.rice.krms.api.repository.term.TermSpecificationDefinition; 014 015 /** 016 * 017 * @author nwright 018 */ 019 public class KrmsTermResolverLoader { 020 021 private TermRepositoryService termRepositoryService = null; 022 023 public TermRepositoryService getTermRepositoryService() { 024 return termRepositoryService; 025 } 026 027 public void setTermRepositoryService(TermRepositoryService termRepositoryService) { 028 this.termRepositoryService = termRepositoryService; 029 } 030 031 public void loadTermResolver(String id, 032 String namespace, 033 String name, 034 String typeId, 035 String outputId, 036 String prereqId1, 037 String prereqId2, 038 String prereqId3) { 039 TermSpecificationDefinition.Builder output = 040 TermSpecificationDefinition.Builder.create(this.getTermRepositoryService().getTermSpecificationById(outputId)); 041 Set<TermSpecificationDefinition.Builder> prerequisites = 042 new LinkedHashSet<TermSpecificationDefinition.Builder>(); 043 if (prereqId1 != null && !prereqId1.isEmpty()) { 044 prerequisites.add(TermSpecificationDefinition.Builder.create(this.getTermRepositoryService().getTermSpecificationById(prereqId1))); 045 } 046 if (prereqId2 != null && !prereqId2.isEmpty()) { 047 prerequisites.add(TermSpecificationDefinition.Builder.create(this.getTermRepositoryService().getTermSpecificationById(prereqId2))); 048 } 049 if (prereqId3 != null && !prereqId3.isEmpty()) { 050 prerequisites.add(TermSpecificationDefinition.Builder.create(this.getTermRepositoryService().getTermSpecificationById(prereqId3))); 051 } 052 Map<String, String> attributes = new HashMap<String, String>(); 053 // TODO: findout what parameter names are used for! 054 Set<String> parameterNames = new LinkedHashSet<String>(); 055 // create(String id, 056 // String namespaceCode, 057 // String name, 058 // String typeId, 059 // TermSpecificationDefinition.Builder output, 060 // Set<TermSpecificationDefinition.Builder> prerequisites, 061 // Map<String, String> attributes, 062 // Set<String> parameterNames) 063 TermResolverDefinition.Builder bldr = TermResolverDefinition.Builder.create(id, 064 namespace, 065 name, 066 typeId, 067 output, 068 prerequisites, 069 attributes, 070 parameterNames); 071 bldr.setActive(true); 072 this.getTermRepositoryService().createTermResolver(bldr.build()); 073 } 074 075 public void load(){ 076 loadTermResolver("10000", "KS-SYS", "CompletedCourse", "10000", "10000", "", "", ""); 077 loadTermResolver("10001", "KS-SYS", "CompletedCourses", "10000", "10001", "", "", ""); 078 loadTermResolver("10002", "KS-SYS", "NumberOfCompletedCourses", "10000", "10002", "", "", ""); 079 loadTermResolver("10003", "KS-SYS", "NumberOfCreditsFromCompletedCourses", "10000", "10003", "", "", ""); 080 loadTermResolver("10004", "KS-SYS", "EnrolledCourses", "10000", "10004", "", "", ""); 081 loadTermResolver("10005", "KS-SYS", "GPAForCourses", "10000", "10005", "", "", ""); 082 loadTermResolver("10006", "KS-SYS", "GradeTypeForCourses", "10000", "10006", "", "", ""); 083 loadTermResolver("10007", "KS-SYS", "NumberOfCredits", "10000", "10007", "", "", ""); 084 loadTermResolver("10008", "KS-SYS", "NumberOfCreditsFromOrganization", "10000", "10008", "", "", ""); 085 loadTermResolver("10009", "KS-SYS", "AdminOrganizationPermissionRequired", "10000", "10009", "", "", ""); 086 loadTermResolver("10010", "KS-SYS", "ScoreOnTest", "10000", "10010", "", "", ""); 087 loadTermResolver("10011", "KS-SYS", "AdmittedToProgram", "10000", "10011", "", "", ""); 088 loadTermResolver("10012", "KS-SYS", "AdmittedToProgramLimitCoursesInOrgForDuration", "10000", "10012", "", "", ""); 089 loadTermResolver("10013", "KS-SYS", "FreeFormText", "10000", "10013", "", "", ""); 090 } 091 092 093 }