1 | |
package org.kuali.student.lum.lu.ui.dependency.client.views; |
2 | |
|
3 | |
|
4 | |
import java.util.ArrayList; |
5 | |
import java.util.Arrays; |
6 | |
import java.util.HashMap; |
7 | |
import java.util.HashSet; |
8 | |
import java.util.List; |
9 | |
import java.util.Map; |
10 | |
import java.util.Set; |
11 | |
|
12 | |
import org.kuali.student.common.assembly.data.LookupMetadata; |
13 | |
import org.kuali.student.common.assembly.data.Metadata; |
14 | |
import org.kuali.student.common.assembly.data.ModelDefinition; |
15 | |
import org.kuali.student.common.search.dto.SearchParam; |
16 | |
import org.kuali.student.common.search.dto.SearchRequest; |
17 | |
import org.kuali.student.common.search.dto.SearchResult; |
18 | |
import org.kuali.student.common.search.dto.SearchResultCell; |
19 | |
import org.kuali.student.common.search.dto.SearchResultRow; |
20 | |
import org.kuali.student.common.ui.client.application.KSAsyncCallback; |
21 | |
import org.kuali.student.common.ui.client.mvc.Callback; |
22 | |
import org.kuali.student.common.ui.client.mvc.Controller; |
23 | |
import org.kuali.student.common.ui.client.mvc.DataModelDefinition; |
24 | |
import org.kuali.student.common.ui.client.mvc.ViewComposite; |
25 | |
import org.kuali.student.common.ui.client.service.MetadataRpcService; |
26 | |
import org.kuali.student.common.ui.client.service.MetadataRpcServiceAsync; |
27 | |
import org.kuali.student.common.ui.client.service.SearchRpcService; |
28 | |
import org.kuali.student.common.ui.client.service.SearchRpcServiceAsync; |
29 | |
import org.kuali.student.common.ui.client.util.UtilConstants; |
30 | |
import org.kuali.student.common.ui.client.widgets.HasWatermark; |
31 | |
import org.kuali.student.common.ui.client.widgets.KSButton; |
32 | |
import org.kuali.student.common.ui.client.widgets.KSLabel; |
33 | |
import org.kuali.student.common.ui.client.widgets.KSButtonAbstract.ButtonStyle; |
34 | |
import org.kuali.student.common.ui.client.widgets.field.layout.element.SpanPanel; |
35 | |
import org.kuali.student.common.ui.client.widgets.field.layout.layouts.VerticalFieldLayout; |
36 | |
import org.kuali.student.common.ui.client.widgets.filter.FilterEvent; |
37 | |
import org.kuali.student.common.ui.client.widgets.filter.FilterEventHandler; |
38 | |
import org.kuali.student.common.ui.client.widgets.filter.FilterResetEventHandler; |
39 | |
import org.kuali.student.common.ui.client.widgets.filter.KSFilterOptions; |
40 | |
import org.kuali.student.common.ui.client.widgets.headers.KSDocumentHeader; |
41 | |
import org.kuali.student.common.ui.client.widgets.layout.HorizontalBlockFlowPanel; |
42 | |
import org.kuali.student.common.ui.client.widgets.layout.VerticalFlowPanel; |
43 | |
import org.kuali.student.common.ui.client.widgets.progress.BlockingTask; |
44 | |
import org.kuali.student.common.ui.client.widgets.progress.KSBlockingProgressIndicator; |
45 | |
import org.kuali.student.common.ui.client.widgets.search.CollapsablePanel; |
46 | |
import org.kuali.student.common.ui.client.widgets.search.KSPicker; |
47 | |
import org.kuali.student.common.ui.client.widgets.suggestbox.KSSuggestBox; |
48 | |
import org.kuali.student.common.ui.client.widgets.suggestbox.IdableSuggestOracle.IdableSuggestion; |
49 | |
import org.kuali.student.core.statement.dto.ReqCompFieldInfo; |
50 | |
import org.kuali.student.core.statement.dto.ReqComponentInfo; |
51 | |
import org.kuali.student.core.statement.dto.StatementTreeViewInfo; |
52 | |
import org.kuali.student.core.statement.ui.client.widgets.rules.RulePreviewWidget; |
53 | |
import org.kuali.student.core.statement.ui.client.widgets.rules.RulesUtil; |
54 | |
import org.kuali.student.lum.common.client.lu.LUUIConstants; |
55 | |
import org.kuali.student.lum.common.client.widgets.AppLocations; |
56 | |
import org.kuali.student.lum.common.client.widgets.CluSetDetailsWidget; |
57 | |
import org.kuali.student.lum.common.client.widgets.CluSetRetriever; |
58 | |
import org.kuali.student.lum.common.client.widgets.CluSetRetrieverImpl; |
59 | |
import org.kuali.student.lum.lu.ui.dependency.client.controllers.DependencyAnalysisController.DependencyViews; |
60 | |
import org.kuali.student.lum.lu.ui.dependency.client.service.DependencyAnalysisRpcService; |
61 | |
import org.kuali.student.lum.lu.ui.dependency.client.service.DependencyAnalysisRpcServiceAsync; |
62 | |
import org.kuali.student.lum.lu.ui.dependency.client.widgets.DependencyResultPanel; |
63 | |
import org.kuali.student.lum.lu.ui.dependency.client.widgets.DependencyResultPanel.DependencyTypeSection; |
64 | |
import org.kuali.student.lum.lu.ui.tools.client.configuration.ClusetView.Picker; |
65 | |
import org.kuali.student.lum.program.dto.ProgramRequirementInfo; |
66 | |
|
67 | |
import com.google.gwt.core.client.GWT; |
68 | |
import com.google.gwt.event.dom.client.ClickEvent; |
69 | |
import com.google.gwt.event.dom.client.ClickHandler; |
70 | |
import com.google.gwt.user.client.Window; |
71 | |
import com.google.gwt.user.client.ui.Anchor; |
72 | |
import com.google.gwt.user.client.ui.FlowPanel; |
73 | |
import com.google.gwt.user.client.ui.HTMLPanel; |
74 | |
import com.google.gwt.user.client.ui.HorizontalPanel; |
75 | |
import com.google.gwt.user.client.ui.Widget; |
76 | |
|
77 | 0 | public class DependencyAnalysisView extends ViewComposite{ |
78 | |
|
79 | 0 | private static CluSetRetriever cluSetRetriever = new CluSetRetrieverImpl(); |
80 | |
|
81 | 0 | protected final BlockingTask initializingTask = new BlockingTask("Loading"); |
82 | |
|
83 | 0 | protected DependencyAnalysisRpcServiceAsync depRpcServiceAsync = GWT.create(DependencyAnalysisRpcService.class); |
84 | 0 | protected MetadataRpcServiceAsync metadataServiceAsync = GWT.create(MetadataRpcService.class); |
85 | 0 | protected SearchRpcServiceAsync searchServiceAsync = GWT.create(SearchRpcService.class); |
86 | |
|
87 | |
private ModelDefinition searchDefinition; |
88 | 0 | private VerticalFieldLayout container = new VerticalFieldLayout(); |
89 | 0 | protected boolean initialized = false; |
90 | |
|
91 | |
protected String selectedCourseId; |
92 | |
protected String selectedCourseCd; |
93 | |
protected String selectedCourseName; |
94 | |
|
95 | |
protected DependencyResultPanel depResultPanel; |
96 | |
protected KSFilterOptions dependencyFilter; |
97 | 0 | protected HorizontalBlockFlowPanel resultContainer = new HorizontalBlockFlowPanel(); |
98 | |
|
99 | 0 | private final BlockingTask loadDataTask = new BlockingTask("Retrieving Data"); |
100 | |
|
101 | |
public DependencyAnalysisView(Controller controller) { |
102 | 0 | super(controller, "Dependency Analysis", DependencyViews.MAIN); |
103 | 0 | this.initWidget(container); |
104 | 0 | this.addStyleName("blockLayout"); |
105 | 0 | this.addStyleName("ks-dependency-container"); |
106 | 0 | } |
107 | |
|
108 | |
@Override |
109 | |
public void beforeShow(final Callback<Boolean> onReadyCallback) { |
110 | 0 | if (!initialized) { |
111 | 0 | KSBlockingProgressIndicator.addTask(initializingTask); |
112 | |
|
113 | |
|
114 | 0 | metadataServiceAsync.getMetadata("dependency", null, null, new KSAsyncCallback<Metadata>(){ |
115 | |
|
116 | |
@Override |
117 | |
public void handleFailure(Throwable caught) { |
118 | 0 | KSBlockingProgressIndicator.removeTask(initializingTask); |
119 | 0 | throw new RuntimeException("Failed to load search definitions.", caught); |
120 | |
} |
121 | |
|
122 | |
@Override |
123 | |
public void onSuccess(Metadata result) { |
124 | 0 | searchDefinition = new DataModelDefinition(result); |
125 | 0 | init(); |
126 | 0 | onReadyCallback.exec(true); |
127 | 0 | initialized = true; |
128 | 0 | KSBlockingProgressIndicator.removeTask(initializingTask); |
129 | 0 | } |
130 | |
}); |
131 | |
} else { |
132 | 0 | onReadyCallback.exec(true); |
133 | |
} |
134 | 0 | } |
135 | |
|
136 | |
protected void init(){ |
137 | 0 | KSDocumentHeader header = new KSDocumentHeader(); |
138 | 0 | header.setTitle("Dependency Analysis"); |
139 | |
|
140 | |
|
141 | 0 | Metadata metaData = searchDefinition.getMetadata("courseId"); |
142 | 0 | final KSPicker triggerPicker = new Picker(metaData.getInitialLookup(), metaData.getAdditionalLookups()); |
143 | 0 | ((HasWatermark)triggerPicker.getInputWidget()).setWatermarkText("Enter course code"); |
144 | |
|
145 | |
|
146 | 0 | KSButton goButton = new KSButton("Go", ButtonStyle.PRIMARY_SMALL); |
147 | 0 | goButton.addClickHandler(new ClickHandler(){ |
148 | |
|
149 | |
@Override |
150 | |
public void onClick(ClickEvent event) { |
151 | 0 | selectedCourseId = triggerPicker.getValue().toString(); |
152 | 0 | KSSuggestBox suggestBox = (KSSuggestBox)triggerPicker.getInputWidget(); |
153 | 0 | IdableSuggestion selectedSuggestion = suggestBox.getCurrentSuggestion(); |
154 | |
|
155 | 0 | selectedCourseName = selectedSuggestion.getAttrMap().get("lu.resultColumn.luOptionalLongName"); |
156 | 0 | if (!selectedCourseId.equals(UtilConstants.IMPOSSIBLE_CHARACTERS)){ |
157 | 0 | KSBlockingProgressIndicator.addTask(loadDataTask); |
158 | 0 | selectedCourseCd = triggerPicker.getDisplayValue(); |
159 | 0 | if (depResultPanel != null){ |
160 | 0 | resultContainer.remove(depResultPanel); |
161 | |
} |
162 | 0 | depResultPanel = new DependencyResultPanel(); |
163 | 0 | depResultPanel.setHeaderTitle(selectedCourseCd + " - " + selectedCourseName); |
164 | 0 | resultContainer.add(depResultPanel); |
165 | 0 | resultContainer.setVisible(true); |
166 | 0 | updateDependencyResults(); |
167 | |
} |
168 | 0 | } |
169 | |
|
170 | |
}); |
171 | |
|
172 | |
|
173 | |
|
174 | 0 | HorizontalPanel pickerPanel = new HorizontalPanel(); |
175 | 0 | pickerPanel.add(triggerPicker); |
176 | 0 | pickerPanel.add(goButton); |
177 | |
|
178 | 0 | FlowPanel searchPanel = new FlowPanel(); |
179 | 0 | searchPanel.addStyleName("ks-dependency-search"); |
180 | 0 | searchPanel.add(new KSLabel("Search for item to view its dependencies")); |
181 | 0 | searchPanel.add(pickerPanel); |
182 | |
|
183 | |
|
184 | 0 | container.setTitleWidget(header); |
185 | 0 | container.addStyleName("blockLayout"); |
186 | 0 | container.addWidget(searchPanel); |
187 | |
|
188 | 0 | List<LookupMetadata> lookups = new ArrayList<LookupMetadata>(); |
189 | 0 | metaData = searchDefinition.getMetadata("filter"); |
190 | 0 | lookups.add(metaData.getInitialLookup()); |
191 | |
|
192 | 0 | dependencyFilter = new KSFilterOptions(metaData.getAdditionalLookups()); |
193 | 0 | dependencyFilter.addFilterEventHandler(new FilterEventHandler(){ |
194 | |
|
195 | |
@Override |
196 | |
public void onDeselect(FilterEvent e) { |
197 | 0 | depResultPanel.hide(e.getFilterKey(), e.getFilterValue()); |
198 | 0 | } |
199 | |
|
200 | |
@Override |
201 | |
public void onSelect(FilterEvent e) { |
202 | 0 | if (e.isInitialSelect()){ |
203 | 0 | depResultPanel.hideAll(); |
204 | |
} |
205 | 0 | depResultPanel.show(e.getFilterKey(), e.getFilterValue()); |
206 | 0 | } |
207 | |
|
208 | |
}); |
209 | |
|
210 | 0 | dependencyFilter.addFilterResetEventHandler(new FilterResetEventHandler(){ |
211 | |
|
212 | |
@Override |
213 | |
public void onReset() { |
214 | 0 | depResultPanel.showAll(); |
215 | 0 | } |
216 | |
}); |
217 | |
|
218 | 0 | resultContainer.add(dependencyFilter); |
219 | 0 | resultContainer.setVisible(false); |
220 | |
|
221 | 0 | container.addWidget(resultContainer); |
222 | 0 | } |
223 | |
|
224 | |
|
225 | |
|
226 | |
|
227 | |
|
228 | |
protected void updateDependencyResults(){ |
229 | |
|
230 | 0 | depResultPanel.addSection(LUUIConstants.DEP_SECTION_COURSE,"Course Dependencies"); |
231 | 0 | depResultPanel.addSection(LUUIConstants.DEP_SECTION_PROGRAM,"Program Dependencies"); |
232 | 0 | depResultPanel.addSection(LUUIConstants.DEP_SECTION_COURSE_SET, "Course Set Inclusions"); |
233 | |
|
234 | 0 | dependencyFilter.reset(); |
235 | |
|
236 | |
|
237 | 0 | SearchRequest searchRequest = new SearchRequest(); |
238 | 0 | searchRequest.setSearchKey("lu.search.dependencyAnalysis"); |
239 | |
|
240 | 0 | SearchParam searchParam = new SearchParam(); |
241 | 0 | searchParam.setKey("lu.queryParam.luOptionalCluId"); |
242 | 0 | searchParam.setValue(selectedCourseId); |
243 | 0 | searchRequest.getParams().add(searchParam); |
244 | |
|
245 | 0 | searchServiceAsync.search(searchRequest, new KSAsyncCallback<SearchResult>(){ |
246 | |
|
247 | |
@Override |
248 | |
public void onSuccess(SearchResult searchResults) { |
249 | 0 | for (SearchResultRow searchResultRow : searchResults.getRows ()) { |
250 | |
|
251 | |
|
252 | 0 | String cluCode = ""; |
253 | 0 | String cluName = ""; |
254 | 0 | String cluType = ""; |
255 | 0 | String dependencyType = ""; |
256 | 0 | String dependencyTypeName = ""; |
257 | 0 | String reqComponentIds = ""; |
258 | 0 | String reqRootId = ""; |
259 | 0 | String cluId = ""; |
260 | 0 | String curriculumOversightNames = ""; |
261 | 0 | String dependencySectionKey = ""; |
262 | 0 | Boolean diffAdminOrg = false; |
263 | |
|
264 | 0 | for (SearchResultCell searchResultCell : searchResultRow.getCells ()){ |
265 | 0 | if (searchResultCell.getKey().equals ("lu.resultColumn.luOptionalCode")) { |
266 | 0 | cluCode = searchResultCell.getValue(); |
267 | 0 | } if (searchResultCell.getKey().equals ("lu.resultColumn.cluId")) { |
268 | 0 | cluId = searchResultCell.getValue(); |
269 | 0 | } else if (searchResultCell.getKey().equals("lu.resultColumn.luOptionalLongName")){ |
270 | 0 | cluName = searchResultCell.getValue(); |
271 | 0 | } else if (searchResultCell.getKey().equals("lu.resultColumn.cluType")){ |
272 | 0 | cluType = searchResultCell.getValue(); |
273 | 0 | if (cluType.equals(LUUIConstants.CLU_TYPE_CREDIT_COURSE)){ |
274 | 0 | dependencySectionKey = LUUIConstants.DEP_SECTION_COURSE; |
275 | 0 | } else if (cluType != null){ |
276 | 0 | dependencySectionKey = LUUIConstants.DEP_SECTION_PROGRAM; |
277 | |
} |
278 | 0 | } else if (searchResultCell.getKey().equals("lu.resultColumn.luOptionalDependencyType")){ |
279 | 0 | dependencyType = searchResultCell.getValue(); |
280 | 0 | if (dependencyType.equals("cluSet")){ |
281 | 0 | dependencySectionKey = LUUIConstants.DEP_SECTION_COURSE_SET; |
282 | 0 | } else if (LUUIConstants.DEP_TYPE_JOINT.equals(dependencyType) || |
283 | |
LUUIConstants.DEP_TYPE_CROSS_LISTED.equals(dependencyType)){ |
284 | 0 | dependencySectionKey = LUUIConstants.DEP_SECTION_COURSE;; |
285 | |
} |
286 | 0 | } else if (searchResultCell.getKey().equals("lu.resultColumn.luOptionalDependencyTypeName")){ |
287 | 0 | dependencyTypeName = searchResultCell.getValue(); |
288 | 0 | } else if (searchResultCell.getKey().equals("lu.resultColumn.luOptionalDependencyRequirementComponentIds")){ |
289 | 0 | reqComponentIds = searchResultCell.getValue(); |
290 | 0 | } else if (searchResultCell.getKey().equals("lu.resultColumn.luOptionalDependencyRootId")){ |
291 | 0 | reqRootId = searchResultCell.getValue(); |
292 | 0 | } else if (searchResultCell.getKey().equals("lu.resultColumn.luOptionalOversightCommitteeNames")){ |
293 | 0 | curriculumOversightNames = searchResultCell.getValue(); |
294 | 0 | } else if (searchResultCell.getKey().equals("lu.resultColumn.luOptionalDependencyRequirementDifferentAdminOrg")){ |
295 | 0 | diffAdminOrg = ("true").equals(searchResultCell.getValue()); |
296 | |
} |
297 | |
|
298 | |
} |
299 | |
|
300 | |
|
301 | 0 | DependencyTypeSection typeSection = depResultPanel.getDependencyTypeSection(dependencySectionKey, dependencyType); |
302 | 0 | if (typeSection == null){ |
303 | 0 | typeSection = depResultPanel.addDependencyTypeSection(dependencySectionKey, dependencyType, getDependencyTypeLabel(dependencySectionKey, dependencyType, dependencyTypeName)); |
304 | |
} |
305 | |
|
306 | |
|
307 | 0 | VerticalFieldLayout depDetails = null; |
308 | 0 | if (hasDependencyDetails(dependencyType)){ |
309 | 0 | depDetails = getDependencyDetails(dependencySectionKey, dependencyType, cluCode, reqRootId, reqComponentIds); |
310 | 0 | KSLabel curricOversightLabel = new KSLabel("Curriculum Oversight: " + curriculumOversightNames); |
311 | 0 | curricOversightLabel.addStyleName("ks-dependency-oversight"); |
312 | 0 | depDetails.addWidget(curricOversightLabel); |
313 | |
} |
314 | |
|
315 | |
|
316 | 0 | typeSection.addDependencyItem(getDependencyLabel(dependencySectionKey, dependencyType, cluId, cluCode, cluName, cluType, diffAdminOrg), depDetails); |
317 | 0 | } |
318 | |
|
319 | 0 | depResultPanel.finishLoad(); |
320 | 0 | KSBlockingProgressIndicator.removeTask(loadDataTask); |
321 | 0 | } |
322 | |
|
323 | |
}); |
324 | 0 | } |
325 | |
|
326 | |
|
327 | |
private VerticalFieldLayout getDependencyDetails(String dependencySectionKey, String dependencyType, final String cluCode, final String rootId, String reqComponentIds){ |
328 | 0 | VerticalFieldLayout depDetails = new VerticalFieldLayout(); |
329 | 0 | depDetails.addStyleName("KS-Dependency-Details"); |
330 | 0 | if (reqComponentIds != null && !reqComponentIds.isEmpty()){ |
331 | 0 | List<String> reqComponentIdList = Arrays.asList(reqComponentIds.split(",")); |
332 | |
|
333 | 0 | final VerticalFlowPanel simpleRequirement = new VerticalFlowPanel(); |
334 | 0 | simpleRequirement.addStyleName("KS-Dependency-Simple-Rule"); |
335 | |
|
336 | |
|
337 | 0 | if (LUUIConstants.DEP_SECTION_PROGRAM.equals(dependencySectionKey)){ |
338 | 0 | final KSButton complexReqLabel = new KSButton("Display complex requirement", ButtonStyle.DEFAULT_ANCHOR); |
339 | 0 | final KSButton simpleReqLabel = new KSButton("Display simple requirement", ButtonStyle.DEFAULT_ANCHOR); |
340 | |
|
341 | |
|
342 | 0 | final FlowPanel complexContent = new FlowPanel(); |
343 | 0 | final CollapsablePanel complexRequirement = new CollapsablePanel("", complexContent, false, false); |
344 | |
|
345 | 0 | complexContent.addStyleName("KS-Dependency-Complex-Rule"); |
346 | 0 | depDetails.addWidget(simpleRequirement); |
347 | 0 | depDetails.addWidget(complexRequirement); |
348 | 0 | depDetails.addWidget(complexReqLabel); |
349 | 0 | depDetails.addWidget(simpleReqLabel); |
350 | |
|
351 | 0 | simpleReqLabel.setVisible(false); |
352 | |
|
353 | |
|
354 | |
|
355 | 0 | complexReqLabel.addClickHandler(new ClickHandler(){ |
356 | |
public void onClick(ClickEvent event) { |
357 | 0 | simpleReqLabel.setVisible(true); |
358 | 0 | simpleRequirement.setVisible(false); |
359 | 0 | complexReqLabel.setVisible(false); |
360 | |
|
361 | 0 | if (complexContent.getWidgetCount() <= 0){ |
362 | 0 | KSBlockingProgressIndicator.addTask(loadDataTask); |
363 | |
|
364 | 0 | depRpcServiceAsync.getProgramRequirement(rootId, new KSAsyncCallback<ProgramRequirementInfo>(){ |
365 | |
public void onSuccess(ProgramRequirementInfo progReqInfo) { |
366 | 0 | int minCredits = (progReqInfo.getMinCredits() == null ? 0 : progReqInfo.getMinCredits()); |
367 | 0 | int maxCredits = (progReqInfo.getMaxCredits() == null ? 0 : progReqInfo.getMaxCredits()); |
368 | 0 | String plainDesc = (progReqInfo.getDescr() == null ? "" : progReqInfo.getDescr().getPlain()); |
369 | 0 | final RulePreviewWidget rulePreviewWidget = new RulePreviewWidget(1, progReqInfo.getShortTitle(), |
370 | |
getTotalCreditsString(minCredits, maxCredits), |
371 | |
plainDesc, progReqInfo.getStatement(), |
372 | |
true, getCluSetWidgetList(progReqInfo.getStatement())); |
373 | 0 | complexContent.add(rulePreviewWidget); |
374 | 0 | KSBlockingProgressIndicator.removeTask(loadDataTask); |
375 | 0 | complexRequirement.open(); |
376 | 0 | } |
377 | |
}); |
378 | |
} else { |
379 | 0 | complexRequirement.open(); |
380 | |
} |
381 | 0 | } |
382 | |
}); |
383 | |
|
384 | |
|
385 | 0 | simpleReqLabel.addClickHandler(new ClickHandler(){ |
386 | |
public void onClick(ClickEvent event) { |
387 | 0 | complexReqLabel.setVisible(true); |
388 | 0 | complexRequirement.close(); |
389 | 0 | simpleRequirement.setVisible(true); |
390 | 0 | simpleReqLabel.setVisible(false); |
391 | 0 | } |
392 | |
}); |
393 | 0 | } else { |
394 | 0 | depDetails.addWidget(simpleRequirement); |
395 | |
} |
396 | |
|
397 | 0 | depRpcServiceAsync.getRequirementComponentNL(reqComponentIdList, new KSAsyncCallback<List<String>>(){ |
398 | |
public void onSuccess(List<String> results) { |
399 | 0 | for (String reqCompNL:results){ |
400 | 0 | int codeIdx = reqCompNL.indexOf(selectedCourseCd); |
401 | 0 | SpanPanel requirement = new SpanPanel(); |
402 | 0 | requirement.setHTML(reqCompNL.substring(0,codeIdx) + |
403 | |
" <b>" + selectedCourseCd + "</b>" + reqCompNL.substring(codeIdx + selectedCourseCd.length())); |
404 | 0 | simpleRequirement.add(requirement); |
405 | 0 | } |
406 | 0 | } |
407 | |
}); |
408 | |
} |
409 | |
|
410 | 0 | return depDetails; |
411 | |
} |
412 | |
|
413 | |
|
414 | |
private SpanPanel getDependencyTypeLabel(String dependencySectionKey, String dependencyType, String dependencyTypeName) { |
415 | 0 | SpanPanel header = new SpanPanel(); |
416 | 0 | if (dependencyType.equals("joint") || dependencyType.equals("crossListed")){ |
417 | 0 | header.setHTML("<b>" + selectedCourseCd + "</b> is <b>" + dependencyTypeName + "</b> with the following "); |
418 | 0 | } else if (dependencySectionKey.equals("course sets")){ |
419 | 0 | header.setHTML("<b>" + selectedCourseCd + "</b> belongs to the following course sets"); |
420 | |
} else { |
421 | 0 | header.setHTML("<b>" + selectedCourseCd + "</b> is a/an <b>" + dependencyTypeName + "</b> for the following " + dependencySectionKey); |
422 | |
} |
423 | 0 | header.setStyleName("KS-DependencyType-Label"); |
424 | 0 | return header; |
425 | |
} |
426 | |
|
427 | |
|
428 | |
|
429 | |
|
430 | |
|
431 | |
private SpanPanel getDependencyLabel(final String dependencySectionKey, String dependencyType, final String cluId, String cluCode, String cluName, String cluType, boolean diffAdminOrg){ |
432 | |
|
433 | |
|
434 | 0 | Anchor viewLinkAnchor = null; |
435 | |
final String viewLinkUrl; |
436 | 0 | if (LUUIConstants.CLU_TYPE_CREDIT_COURSE.equals(cluType) && |
437 | |
!LUUIConstants.DEP_TYPE_CROSS_LISTED.equals(dependencyType)){ |
438 | 0 | viewLinkAnchor = new Anchor("View Course"); |
439 | 0 | viewLinkUrl = AppLocations.Locations.VIEW_COURSE.toString(); |
440 | 0 | } else if ("kuali.lu.type.MajorDiscipline".equals(cluType) || "kuali.lu.type.Variation".equals(cluType)){ |
441 | 0 | viewLinkAnchor = new Anchor("View Program "); |
442 | 0 | viewLinkUrl = AppLocations.Locations.VIEW_PROGRAM.toString(); |
443 | 0 | } else if ("kuali.lu.type.CoreProgram".equals(cluType)){ |
444 | 0 | viewLinkAnchor = new Anchor("View Program "); |
445 | 0 | viewLinkUrl = AppLocations.Locations.VIEW_CORE_PROGRAM.toString(); |
446 | 0 | } else if (cluType.startsWith("kuali.lu.type.credential")){ |
447 | 0 | viewLinkAnchor = new Anchor("View Program "); |
448 | 0 | viewLinkUrl = AppLocations.Locations.VIEW_BACC_PROGRAM.toString(); |
449 | 0 | } else if (LUUIConstants.DEP_TYPE_COURSE_SET.equals(dependencyType)){ |
450 | 0 | viewLinkAnchor = new Anchor("View Course Set"); |
451 | 0 | viewLinkUrl = AppLocations.Locations.VIEW_CLU_SET.toString(); |
452 | |
} else { |
453 | 0 | viewLinkUrl = null; |
454 | |
} |
455 | |
|
456 | |
|
457 | 0 | if (viewLinkAnchor != null){ |
458 | 0 | viewLinkAnchor.addStyleName("KS-Dependency-View-Link"); |
459 | 0 | viewLinkAnchor.addClickHandler(new ClickHandler(){ |
460 | |
|
461 | |
@Override |
462 | |
public void onClick(ClickEvent event) { |
463 | 0 | String url = "http://" + Window.Location.getHost() + Window.Location.getPath() + |
464 | |
"?view=" + viewLinkUrl + "&docId=" + cluId; |
465 | 0 | String features = "height=600,width=960,dependent=0,directories=1," + |
466 | |
"fullscreen=1,location=1,menubar=1,resizable=1,scrollbars=1,status=1,toolbar=1"; |
467 | 0 | Window.open(url, HTMLPanel.createUniqueId(), features); |
468 | 0 | } |
469 | |
}); |
470 | |
} |
471 | |
|
472 | |
|
473 | 0 | String orgHighlight = (diffAdminOrg ? " <span class=\"ks-dependency-highlight\">Different Org</span> ":""); |
474 | |
|
475 | |
|
476 | 0 | String headerLabel = ""; |
477 | 0 | if (LUUIConstants.DEP_TYPE_CROSS_LISTED.equals(dependencyType)){ |
478 | 0 | headerLabel = cluCode + " - " + selectedCourseName + orgHighlight; |
479 | 0 | } else if (LUUIConstants.DEP_TYPE_COURSE_SET.equals(dependencyType)){ |
480 | 0 | headerLabel = cluName; |
481 | |
} else { |
482 | 0 | headerLabel = cluCode + " - " + cluName + orgHighlight; |
483 | |
} |
484 | |
|
485 | |
|
486 | 0 | SpanPanel header = new SpanPanel(); |
487 | 0 | header.setStyleName("KS-DependencyType-Label"); |
488 | 0 | header.setHTML(headerLabel); |
489 | 0 | if (viewLinkAnchor != null){ |
490 | 0 | header.add(viewLinkAnchor); |
491 | |
} |
492 | |
|
493 | 0 | return header; |
494 | |
} |
495 | |
|
496 | |
protected boolean hasDependencyDetails(String dependencyType){ |
497 | |
|
498 | |
|
499 | 0 | return !(LUUIConstants.DEP_TYPE_JOINT.equals(dependencyType) || |
500 | |
LUUIConstants.DEP_TYPE_CROSS_LISTED.equals(dependencyType) || |
501 | |
LUUIConstants.DEP_TYPE_COURSE_SET.equals(dependencyType)); |
502 | |
} |
503 | |
|
504 | |
private String getTotalCreditsString(int min, int max) { |
505 | 0 | return "Expected Total Credits:" + min + "-" + max; |
506 | |
} |
507 | |
|
508 | |
|
509 | |
protected Map<String, Widget> getCluSetWidgetList(StatementTreeViewInfo rule) { |
510 | 0 | Map<String, Widget> widgetList = new HashMap<String, Widget>(); |
511 | 0 | Set<String> cluSetIds = new HashSet<String>(); |
512 | 0 | findCluSetIds(rule, cluSetIds); |
513 | 0 | for (String clusetId : cluSetIds) { |
514 | 0 | widgetList.put(clusetId, new CluSetDetailsWidget(clusetId, cluSetRetriever)); |
515 | |
} |
516 | |
|
517 | 0 | return widgetList; |
518 | |
} |
519 | |
|
520 | |
|
521 | |
private void findCluSetIds(StatementTreeViewInfo rule, Set<String> list) { |
522 | |
|
523 | 0 | List<StatementTreeViewInfo> statements = rule.getStatements(); |
524 | 0 | List<ReqComponentInfo> reqComponentInfos = rule.getReqComponents(); |
525 | |
|
526 | 0 | if ((statements != null) && (statements.size() > 0)) { |
527 | |
|
528 | 0 | for (StatementTreeViewInfo statement : statements) { |
529 | 0 | findCluSetIds(statement, list); |
530 | |
} |
531 | 0 | } else if ((reqComponentInfos != null) && (reqComponentInfos.size() > 0)) { |
532 | |
|
533 | 0 | for (ReqComponentInfo reqComponent : reqComponentInfos) { |
534 | 0 | List<ReqCompFieldInfo> fieldInfos = reqComponent.getReqCompFields(); |
535 | 0 | for (ReqCompFieldInfo fieldInfo : fieldInfos) { |
536 | 0 | if (RulesUtil.isCluSetWidget(fieldInfo.getType())) { |
537 | 0 | list.add(fieldInfo.getValue()); |
538 | |
} |
539 | |
} |
540 | 0 | } |
541 | |
} |
542 | 0 | } |
543 | |
|
544 | |
} |