Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
NLCluSet |
|
| 2.5;2.5 |
1 | /** | |
2 | * Copyright 2010 The Kuali Foundation Licensed under the | |
3 | * Educational Community License, Version 2.0 (the "License"); you may | |
4 | * not use this file except in compliance with the License. You may | |
5 | * obtain a copy of the License at | |
6 | * | |
7 | * http://www.osedu.org/licenses/ECL-2.0 | |
8 | * | |
9 | * Unless required by applicable law or agreed to in writing, | |
10 | * software distributed under the License is distributed on an "AS IS" | |
11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | |
12 | * or implied. See the License for the specific language governing | |
13 | * permissions and limitations under the License. | |
14 | */ | |
15 | ||
16 | package org.kuali.student.lum.statement.config.context.util; | |
17 | ||
18 | import java.util.List; | |
19 | ||
20 | import org.kuali.student.lum.lu.dto.CluInfo; | |
21 | ||
22 | /** | |
23 | * <p><b><u>Warning</u></b><br/> | |
24 | * DO NOT change the public method signatures of this class.<br/> | |
25 | * The natural language templates are coded against this class's public methods. | |
26 | * If the method signatures are changed then all the templates referencing | |
27 | * this class will need to be changed as well.</p> | |
28 | * | |
29 | * This class is inserted into the template engine to get Clu and CluSet | |
30 | * information. <code>$cluSet</code> is this class. | |
31 | * <p> | |
32 | * Example: | |
33 | * <code>"Student must have completed $intValue of $cluSet.getCluSetAsShortName()"</code> | |
34 | * </p> | |
35 | * | |
36 | * {@link MockCluSetInfo} wrapper class. | |
37 | */ | |
38 | public class NLCluSet { | |
39 | ||
40 | private String cluSetId; | |
41 | private List<CluInfo> cluList; | |
42 | ||
43 | 40 | public NLCluSet(String cluSetId, List<CluInfo> cluList) { |
44 | 40 | this.cluSetId = cluSetId; |
45 | 40 | this.cluList = cluList; |
46 | 40 | } |
47 | ||
48 | /** | |
49 | * Gets the CLU set id. | |
50 | * | |
51 | * @return Clu set id | |
52 | */ | |
53 | public String getCluSetId() { | |
54 | 4 | return cluSetId; |
55 | } | |
56 | ||
57 | /** | |
58 | * Gets a list of CLUs. | |
59 | * | |
60 | * @return List of CLUs | |
61 | */ | |
62 | public List<CluInfo> getCluList() { | |
63 | 8 | return this.cluList; |
64 | } | |
65 | ||
66 | /** | |
67 | * Gets a particular CLU's official identifier short name. | |
68 | * | |
69 | * @param index Index in CLU set | |
70 | * @return CLU official identifier short name | |
71 | */ | |
72 | public String getCluAsShortName(int index) { | |
73 | 2 | return this.cluList.get(index).getOfficialIdentifier().getShortName(); |
74 | } | |
75 | ||
76 | /** | |
77 | * Gets a particular CLU's official identifier code at <code>index</code> | |
78 | * @param index | |
79 | * @return CLU's official identifier code | |
80 | */ | |
81 | public String getCluAsCode(int index) { | |
82 | 2 | return this.cluList.get(index).getOfficialIdentifier().getCode(); |
83 | } | |
84 | ||
85 | /** | |
86 | * Gets all the CLUs' official identifier short name in the CLU set | |
87 | * as a comma separated list. | |
88 | * | |
89 | * @return Comma separated list of CLUs' official identifier short name | |
90 | */ | |
91 | public String getCluSetAsShortName() { | |
92 | 1 | StringBuilder sb = new StringBuilder(); |
93 | 1 | if (this.cluList.size() > 1) { |
94 | 1 | sb.append("("); |
95 | } | |
96 | 1 | for(CluInfo clu : this.cluList) { |
97 | 2 | sb.append(clu.getOfficialIdentifier().getShortName()); |
98 | 2 | if (this.cluList.indexOf(clu) < (this.cluList.size() - 1)) { |
99 | 1 | sb.append(", "); |
100 | } | |
101 | } | |
102 | 1 | if (this.cluList.size() > 1) { |
103 | 1 | sb.append(")"); |
104 | } | |
105 | 1 | return getString(sb); |
106 | } | |
107 | ||
108 | /** | |
109 | * Gets all the CLUs' official identifier long name in the CLU set | |
110 | * as a comma separated list. | |
111 | * | |
112 | * @return Comma separated list of CLUs' official identifier long name | |
113 | */ | |
114 | public String getCluSetAsLongName() { | |
115 | 7 | StringBuilder sb = new StringBuilder(); |
116 | 7 | if (this.cluList.size() > 1) { |
117 | 1 | sb.append("("); |
118 | } | |
119 | 7 | for(CluInfo clu : this.cluList) { |
120 | 8 | sb.append(clu.getOfficialIdentifier().getLongName()); |
121 | 8 | if (this.cluList.indexOf(clu) < (this.cluList.size() - 1)) { |
122 | 1 | sb.append(", "); |
123 | } | |
124 | } | |
125 | 7 | if (this.cluList.size() > 1) { |
126 | 1 | sb.append(")"); |
127 | } | |
128 | 7 | return getString(sb); |
129 | } | |
130 | ||
131 | /** | |
132 | * Gets all the CLUs' official identifier code in the CLU set | |
133 | * as a comma separated list. | |
134 | * | |
135 | * @return Comma separated list of CLUs' official identifier code | |
136 | */ | |
137 | public String getCluSetAsCode() { | |
138 | 27 | StringBuilder sb = new StringBuilder(); |
139 | 27 | if (this.cluList.size() > 1) { |
140 | 23 | sb.append("("); |
141 | } | |
142 | 27 | for(CluInfo clu : this.cluList) { |
143 | 53 | sb.append(clu.getOfficialIdentifier().getCode()); |
144 | 53 | if (this.cluList.indexOf(clu) < (this.cluList.size() - 1)) { |
145 | 26 | sb.append(", "); |
146 | } | |
147 | } | |
148 | 27 | if (this.cluList.size() > 1) { |
149 | 23 | sb.append(")"); |
150 | } | |
151 | 27 | return getString(sb); |
152 | } | |
153 | ||
154 | private String getString(StringBuilder sb) { | |
155 | 35 | return (sb.length() == 0 ? "No CLUs available in CluSet" : sb.toString()); |
156 | } | |
157 | ||
158 | public String toString() { | |
159 | 0 | if(this.cluList == null) { |
160 | 0 | return "Null CluSet"; |
161 | } | |
162 | 0 | return "id=" + this.cluSetId; |
163 | } | |
164 | } |