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