1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.student.r2.lum.statement.config.context.util;
17
18 import java.util.List;
19
20 import org.kuali.student.r2.common.search.dto.SearchParamInfo;
21 import org.kuali.student.r2.lum.clu.dto.CluInfo;
22 import org.kuali.student.r2.lum.clu.dto.CluSetInfo;
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41 public class NLCluSet {
42
43 private String cluSetId;
44 private List<CluInfo> cluList;
45 private CluSetInfo cluSet;
46
47 public NLCluSet(String cluSetId, List<CluInfo> cluList) {
48 this.cluSetId = cluSetId;
49 this.cluList = cluList;
50 }
51
52 public NLCluSet(String cluSetId, List<CluInfo> cluList, CluSetInfo cluSet) {
53 this.cluSetId = cluSetId;
54 this.cluList = cluList;
55 this.cluSet = cluSet;
56 }
57
58
59
60
61
62
63 public String getCluSetId() {
64 return cluSetId;
65 }
66
67
68
69
70
71
72 public List<CluInfo> getCluList() {
73 return this.cluList;
74 }
75
76
77
78
79
80
81
82 public String getCluAsShortName(int index) {
83 return this.cluList.get(index).getOfficialIdentifier().getShortName();
84 }
85
86
87
88
89
90
91 public String getCluAsCode(int index) {
92 return this.cluList.get(index).getOfficialIdentifier().getCode();
93 }
94
95
96
97
98
99
100
101 public String getCluSetAsShortName() {
102 return getCluSetAsShortName(",");
103 }
104
105
106
107
108
109
110
111
112 public String getCluSetAsShortName(String separator) {
113 StringBuilder sb = new StringBuilder();
114 if (this.cluList.size() > 1) {
115 sb.append("(");
116 }
117 for(CluInfo clu : this.cluList) {
118 sb.append(clu.getOfficialIdentifier().getShortName());
119 if (this.cluList.indexOf(clu) < (this.cluList.size() - 1)) {
120 sb.append(separator + " ");
121 }
122 }
123 if (this.cluList.size() > 1) {
124 sb.append(")");
125 }
126 return getString(sb);
127 }
128
129
130
131
132
133
134
135 public String getCluSetAsLongName() {
136 return getCluSetAsLongName(",");
137 }
138
139
140
141
142
143
144
145
146 public String getCluSetAsLongName(String separator) {
147 StringBuilder sb = new StringBuilder();
148 if (this.cluList.size() > 1) {
149 sb.append("(");
150 }
151 for(CluInfo clu : this.cluList) {
152 sb.append(clu.getOfficialIdentifier().getLongName());
153 if (this.cluList.indexOf(clu) < (this.cluList.size() - 1)) {
154 sb.append(separator + " ");
155 }
156 }
157 if (this.cluList.size() > 1) {
158 sb.append(")");
159 }
160 return getString(sb);
161 }
162
163
164
165
166
167
168
169 public String getCluSetAsCode() {
170 return getCluSetAsCode(",");
171 }
172
173
174
175
176
177
178
179
180 public String getCluSetAsCode(String separator) {
181 StringBuilder sb = new StringBuilder();
182 if (this.cluList.size() > 1) {
183 sb.append("(");
184 }
185 for(CluInfo clu : this.cluList) {
186 sb.append(clu.getOfficialIdentifier().getCode());
187 if (this.cluList.indexOf(clu) < (this.cluList.size() - 1)) {
188 sb.append(separator + " ");
189 }
190 }
191 if (this.cluList.size() > 1) {
192 sb.append(")");
193 }
194 return getString(sb);
195 }
196
197 private String getString(StringBuilder sb) {
198 return (sb.length() == 0 ? "No CLUs available in CluSet" : sb.toString());
199 }
200
201 public String toString() {
202 if(this.cluList == null) {
203 return "Null CluSet";
204 }
205 return "id=" + this.cluSetId;
206 }
207
208 public String getQueryValueFromParam(String param) {
209 String value = "";
210 if (cluSet.getMembershipQuery() != null && !cluSet.getMembershipQuery().getQueryParamValues().isEmpty())
211 for (SearchParamInfo searchParam : cluSet.getMembershipQuery().getQueryParamValues())
212 if (searchParam.getKey().equals(param))
213 return searchParam.getValues().get(0);
214 return value;
215 }
216 }