1 package org.kuali.student.lum.lu.ui.main.client.controllers;
2
3 import java.util.Map;
4
5 import org.kuali.student.common.ui.client.application.Application;
6 import org.kuali.student.common.ui.client.application.ViewContext;
7 import org.kuali.student.common.ui.client.configurable.mvc.LayoutController;
8 import org.kuali.student.common.ui.client.mvc.Callback;
9 import org.kuali.student.common.ui.client.mvc.Controller;
10 import org.kuali.student.common.ui.client.mvc.View;
11 import org.kuali.student.common.ui.client.util.WindowTitleUtils;
12 import org.kuali.student.common.ui.client.widgets.field.layout.element.SpanPanel;
13 import org.kuali.student.common.ui.shared.IdAttributes.IdType;
14 import org.kuali.student.lum.common.client.configuration.LUMViews;
15 import org.kuali.student.lum.common.client.widgets.AppLocations;
16 import org.kuali.student.lum.lu.ui.browseprogram.client.controllers.BrowseProgramController;
17 import org.kuali.student.lum.lu.ui.course.client.configuration.CourseRetireByProposalConfigurer;
18 import org.kuali.student.lum.lu.ui.course.client.controllers.CourseAdminController;
19 import org.kuali.student.lum.lu.ui.course.client.controllers.CourseAdminRetireController;
20 import org.kuali.student.lum.lu.ui.course.client.controllers.CourseAdminWithoutVersionController;
21 import org.kuali.student.lum.lu.ui.course.client.controllers.CourseProposalController;
22 import org.kuali.student.lum.lu.ui.course.client.controllers.CourseRetireByProposalController;
23 import org.kuali.student.lum.lu.ui.course.client.controllers.ViewCourseParentController;
24 import org.kuali.student.lum.lu.ui.course.client.views.CategoryManagementView;
25 import org.kuali.student.lum.lu.ui.course.client.views.CurriculumHomeView;
26 import org.kuali.student.lum.lu.ui.dependency.client.controllers.DependencyAnalysisController;
27 import org.kuali.student.lum.lu.ui.tools.client.configuration.CatalogBrowserController;
28 import org.kuali.student.lum.lu.ui.tools.client.configuration.CluSetsManagementController;
29 import org.kuali.student.lum.program.client.ProgramConstants;
30 import org.kuali.student.lum.program.client.ProgramRegistry;
31 import org.kuali.student.lum.program.client.core.CoreManager;
32 import org.kuali.student.lum.program.client.credential.CredentialManager;
33 import org.kuali.student.lum.program.client.major.MajorManager;
34
35 import com.google.gwt.core.client.GWT;
36 import com.google.gwt.core.client.RunAsyncCallback;
37 import com.google.gwt.user.client.Window;
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66 public class CurriculumHomeController extends LayoutController {
67
68 private CurriculumHomeView home;
69 private final SpanPanel panel = new SpanPanel();
70
71 private CourseProposalController courseProposalController;
72 private CourseRetireByProposalController courseRetireByProposalController;
73 private CourseAdminController courseAdminController;
74 private CourseAdminWithoutVersionController courseAdminWithoutVersionController;
75 private CourseAdminRetireController courseAdminRetireController;
76 private LayoutController viewCourseController;
77 private LayoutController manageCluSetsController;
78 private LayoutController browseCatalogController;
79 private LayoutController dependencyAnalysisController;
80 private LayoutController browseProgramController;
81 private MajorManager majorManager = new MajorManager();
82 private CredentialManager credentialManager = new CredentialManager();
83 private CoreManager coreManager = new CoreManager();
84
85 private abstract class RunAsyncGetView implements RunAsyncCallback {
86 public void onFailure(Throwable reason) {
87 Window.alert("Download failed. Please try again.");
88 }
89 }
90
91 public CurriculumHomeController() {
92 super();
93 this.setDefaultView(LUMViews.DEFAULT);
94 this.initWidget(panel);
95 setupDefaultView();
96 }
97
98 public CurriculumHomeController(Controller controller, String name, Enum<?> viewType) {
99 super();
100 super.setController(controller);
101 super.setName(name);
102 super.setViewEnum(viewType);
103 this.setDefaultView(LUMViews.DEFAULT);
104 this.initWidget(panel);
105 setupDefaultView();
106 }
107
108 private void setupDefaultView() {
109 home = new CurriculumHomeView(this, LUMViews.DEFAULT);
110 }
111
112 @Override
113 public <V extends Enum<?>> void getView(V viewType, final Callback<View> callback, Map<String, String> tokenMap) {
114
115
116 switch ((LUMViews) viewType) {
117 case DEFAULT:
118 callback.exec(home);
119 break;
120 case COURSE_PROPOSAL:
121
122
123
124 callback.exec(getCourseProposalController());
125
126
127 break;
128 case COURSE_RETIRE_BY_PROPOSAL:
129
130
131
132 callback.exec(getCourseRetirebyProposalController());
133
134
135 break;
136 case COURSE_ADMIN:
137
138
139
140 callback.exec(getCourseAdminController());
141
142
143 break;
144 case COURSE_ADMIN_NO_VERSION:
145
146
147
148 callback.exec(getCourseAdminWithoutVersionController());
149
150
151 break;
152 case COURSE_ADMIN_RETIRE:
153
154
155
156 callback.exec(getCourseAdminRetireController());
157
158
159 break;
160
161 case VIEW_COURSE:
162
163
164
165 callback.exec(getViewCourseController());
166
167
168 break;
169 case PROGRAM_PROPOSAL:
170
171
172
173 if (ProgramRegistry.isCreateNew()) {
174 ProgramRegistry.setCreateNew(false);
175 majorManager = new MajorManager();
176 }
177 callback.exec(majorManager.getMajorProposalController());
178
179
180 break;
181 case PROGRAM_VIEW:
182
183
184
185 if (ProgramRegistry.isCreateNew()) {
186 ProgramRegistry.setCreateNew(false);
187 majorManager = new MajorManager();
188 }
189 callback.exec(majorManager.getProgramViewController());
190
191
192 break;
193 case PROGRAM_EDIT:
194
195
196
197 Application.getApplicationContext().setParentPath("");
198 if (ProgramRegistry.isCreateNew()) {
199 ProgramRegistry.setCreateNew(false);
200 majorManager = new MajorManager();
201 }
202 callback.exec(majorManager.getProgramEditController());
203
204
205 break;
206 case PROGRAM_SPEC_EDIT:
207
208
209
210 if (ProgramRegistry.isCreateNew()) {
211 ProgramRegistry.setCreateNew(false);
212 majorManager = new MajorManager();
213 }
214 callback.exec(majorManager.getProgramSpecEditController());
215
216
217 break;
218 case PROGRAM_CREATE:
219
220
221
222 majorManager = new MajorManager();
223 callback.exec(majorManager.getProgramEditController());
224
225
226 break;
227 case PROGRAM_VERSIONS:
228
229
230
231 callback.exec(majorManager.getProgramVersionsController());
232
233
234 break;
235 case CLU_SETS:
236
237
238
239 callback.exec(getCluSetsController());
240
241
242 break;
243 case COURSE_CATALOG:
244
245
246
247 callback.exec(getBrowseCatalogController());
248
249
250 break;
251 case VARIATION_VIEW:
252
253
254
255
256 if(majorManager.getProgramModel()!=null && majorManager.getProgramModel().getDefinition()!=null){
257 callback.exec(majorManager.getVariationViewController());
258 }else{
259
260
261
262 ViewContext viewContext = new ViewContext();
263 viewContext.setId(tokenMap.get("docId"));
264 viewContext.setAttribute(ProgramConstants.VARIATION_ID, tokenMap.get(ProgramConstants.VARIATION_ID));
265 viewContext.setAttribute(ProgramConstants.TYPE, ProgramConstants.VARIATION_TYPE_KEY);
266 viewContext.setIdType(IdType.OBJECT_ID);
267 ProgramRegistry.setCreateNew(true);
268 Application.navigate(AppLocations.Locations.VIEW_PROGRAM.getLocation(), viewContext);
269 }
270
271
272 break;
273 case VARIATION_EDIT:
274
275
276
277 if(majorManager.getProgramModel()!=null && majorManager.getProgramModel().getDefinition()!=null){
278 callback.exec(majorManager.getVariationEditController());
279 }else{
280
281 Application.getApplicationContext().setParentPath("");
282 if (ProgramRegistry.isCreateNew()) {
283 ProgramRegistry.setCreateNew(false);
284 majorManager = new MajorManager();
285 }
286 callback.exec(majorManager.getProgramEditController());
287 }
288
289
290 break;
291 case CORE_PROGRAM_VIEW:
292
293
294
295 if (ProgramRegistry.isCreateNew()) {
296 ProgramRegistry.setCreateNew(false);
297 coreManager = new CoreManager();
298 }
299 callback.exec(coreManager.getViewController());
300
301
302 break;
303 case CORE_PROGRAM_EDIT:
304
305
306
307 callback.exec(coreManager.getEditController());
308
309
310 break;
311 case CORE_PROGRAM_VERSIONS:
312
313
314
315 callback.exec(coreManager.getProgramVersionsController());
316
317
318 break;
319 case BACC_PROGRAM_VIEW:
320
321
322
323 if (ProgramRegistry.isCreateNew()) {
324 ProgramRegistry.setCreateNew(false);
325 credentialManager = new CredentialManager();
326 }
327 callback.exec(credentialManager.getBaccViewController());
328
329
330 break;
331 case BACC_PROGRAM_EDIT:
332
333
334
335 callback.exec(credentialManager.getBaccEditController());
336
337
338 break;
339 case BACC_PROGRAM_VERSIONS:
340
341
342
343 callback.exec(credentialManager.getProgramVersionsController());
344
345
346 break;
347 case LO_CATEGORIES:
348
349
350
351 callback.exec(getCategoryManagementController());
352
353
354 break;
355 case DEPENDENCY_ANALYSIS:
356
357
358
359 callback.exec(getDependencyAnalysisController());
360
361
362 break;
363 case BROWSE_PROGRAM:
364
365
366
367 callback.exec(getBrowseProgramController());
368
369
370 break;
371 default:
372 callback.exec(home);
373 }
374 }
375
376
377 protected View getCategoryManagementController() {
378 return new CategoryManagementView(this, "Learning Objective Categories", LUMViews.LO_CATEGORIES);
379 }
380
381 private CourseProposalController getCourseProposalController() {
382 courseProposalController = GWT.create(CourseProposalController.class);
383 return courseProposalController;
384 }
385
386 private CourseProposalController getCourseRetirebyProposalController(){
387 courseRetireByProposalController = GWT.create(CourseRetireByProposalController.class);
388 return courseRetireByProposalController;
389 }
390
391 private CourseAdminController getCourseAdminController() {
392 courseAdminController = GWT.create(CourseAdminController.class);
393 return courseAdminController;
394 }
395
396 private CourseAdminWithoutVersionController getCourseAdminRetireController(){
397 courseAdminRetireController = GWT.create(CourseAdminRetireController.class);
398 return courseAdminRetireController;
399 }
400
401 private CourseAdminWithoutVersionController getCourseAdminWithoutVersionController(){
402 courseAdminWithoutVersionController = GWT.create(CourseAdminWithoutVersionController.class);
403 return courseAdminWithoutVersionController;
404 }
405
406 private LayoutController getViewCourseController() {
407 if (viewCourseController == null) {
408 viewCourseController = GWT.create(ViewCourseParentController.class);
409 }
410 return this.viewCourseController;
411 }
412
413 private LayoutController getCluSetsController() {
414 manageCluSetsController = GWT.create(CluSetsManagementController.class);
415 return manageCluSetsController;
416 }
417
418 private LayoutController getBrowseCatalogController() {
419 browseCatalogController = new CatalogBrowserController(this);
420 return browseCatalogController;
421 }
422
423 private LayoutController getDependencyAnalysisController() {
424 dependencyAnalysisController = new DependencyAnalysisController("DependencyAnalaysis");
425 return dependencyAnalysisController;
426 }
427
428 private LayoutController getBrowseProgramController() {
429 browseProgramController = new BrowseProgramController("BrowseProgram");
430 return browseProgramController;
431 }
432
433 @Override
434 protected void hideView(View view) {
435 ApplicationController.getApplicationViewContainer().clear();
436 }
437
438 @Override
439 protected void renderView(View view) {
440 ApplicationController.getApplicationViewContainer().add(view.asWidget());
441 }
442
443 @Override
444 public Enum<?> getViewEnumValue(String enumValue) {
445 return LUMViews.valueOf(enumValue);
446 }
447
448 @Override
449 public void updateModel() {
450
451 }
452
453 public <V extends Enum<?>> void showView(V viewType, Callback<Boolean> onReadyCallback) {
454 if (viewType == LUMViews.DEFAULT) {
455 WindowTitleUtils.setContextTitle(name);
456 }
457 super.showView(viewType, onReadyCallback);
458 }
459 }