Coverage Report - org.kuali.student.lum.lu.ui.main.client.controllers.CurriculumHomeController
 
Classes in this File Line Coverage Branch Coverage Complexity
CurriculumHomeController
0%
0/140
0%
0/53
2.857
CurriculumHomeController$1
0%
0/1
N/A
2.857
CurriculumHomeController$RunAsyncGetView
0%
0/3
N/A
2.857
 
 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  
  * Curriculum home controller which controls the main LayoutController views of the lum application.  The
 41  
  * default view of this controller is the Curriculum Home Landing page.  The following views are views within
 42  
  * this controller's scope:<br>
 43  
  *                 COURSE_PROPOSAL<br>
 44  
         COURSE_RETIRE_BY_PROPOSAL<br>
 45  
         VIEW_COURSE<br>
 46  
         PROGRAM_VIEW<br>
 47  
         PROGRAM_EDIT<br>
 48  
         PROGRAM_CREATE<br>
 49  
         PROGRAM_VERSIONS<br>
 50  
         CLU_SETS<br>
 51  
         VARIATION_VIEW<br>
 52  
         VARIATION_EDIT<br>
 53  
         COURSE_CATALOG<br>
 54  
         LO_CATEGORIES<br>
 55  
         BACC_PROGRAM_VIEW<br>
 56  
         BACC_PROGRAM_EDIT<br>
 57  
         BACC_PROGRAM_VERSIONS<br>
 58  
         CORE_PROGRAM_VIEW<br>
 59  
         CORE_PROGRAM_EDIT<br>
 60  
         CORE_PROGRAM_VERSIONS<br>
 61  
  * These views can be accessed through links and searches provided by the CurriculumHomeView (the default view).
 62  
  * 
 63  
  * @author Kuali Student Team
 64  
  * @see CurriculumHomeView
 65  
  */
 66  
 public class CurriculumHomeController extends LayoutController {
 67  
 
 68  
     private CurriculumHomeView home;
 69  0
     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  0
     private MajorManager majorManager = new MajorManager();
 82  0
     private CredentialManager credentialManager = new CredentialManager();
 83  0
     private CoreManager coreManager = new CoreManager();
 84  
 
 85  0
     private abstract class RunAsyncGetView implements RunAsyncCallback {
 86  
         public void onFailure(Throwable reason) {
 87  0
             Window.alert("Download failed.  Please try again.");
 88  0
         }
 89  
     }
 90  
     
 91  
     public CurriculumHomeController() {
 92  0
         super();
 93  0
         this.setDefaultView(LUMViews.DEFAULT);
 94  0
         this.initWidget(panel);
 95  0
         setupDefaultView();
 96  0
     }
 97  
 
 98  
     public CurriculumHomeController(Controller controller, String name, Enum<?> viewType) {
 99  0
         super();
 100  0
         super.setController(controller);
 101  0
         super.setName(name);
 102  0
         super.setViewEnum(viewType);
 103  0
         this.setDefaultView(LUMViews.DEFAULT);
 104  0
         this.initWidget(panel);
 105  0
         setupDefaultView();
 106  0
     }
 107  
 
 108  
     private void setupDefaultView() {
 109  0
         home = new CurriculumHomeView(this, LUMViews.DEFAULT);
 110  0
     }
 111  
 
 112  
     @Override
 113  
     public <V extends Enum<?>> void getView(V viewType, final Callback<View> callback, Map<String, String> tokenMap) {
 114  
         //this is done so the views can have delayed loading
 115  
 
 116  0
         switch ((LUMViews) viewType) {
 117  
             case DEFAULT:
 118  0
                 callback.exec(home);
 119  0
                 break;
 120  
             case COURSE_PROPOSAL:
 121  
 //                GWT.runAsync(new RunAsyncGetView() {
 122  
 //                    @Override
 123  
 //                    public void onSuccess() {
 124  0
                         callback.exec(getCourseProposalController());
 125  
 //                    }
 126  
 //                });
 127  0
                 break;
 128  
             case COURSE_RETIRE_BY_PROPOSAL:
 129  
 //              GWT.runAsync(new RunAsyncGetView() {
 130  
 //                  @Override
 131  
 //                  public void onSuccess() {
 132  0
                       callback.exec(getCourseRetirebyProposalController());
 133  
 //                  }
 134  
 //              });
 135  0
               break;                
 136  
             case COURSE_ADMIN:
 137  
 //                GWT.runAsync(new RunAsyncGetView() {
 138  
 //                    @Override
 139  
 //                    public void onSuccess() {
 140  0
                         callback.exec(getCourseAdminController());
 141  
 //                    }
 142  
 //                });
 143  0
                 break;
 144  
             case COURSE_ADMIN_NO_VERSION:
 145  
 //                GWT.runAsync(new RunAsyncGetView() {
 146  
 //                    @Override
 147  
 //                    public void onSuccess() {
 148  0
                         callback.exec(getCourseAdminWithoutVersionController());
 149  
 //                    }
 150  
 //                });
 151  0
                 break;
 152  
             case COURSE_ADMIN_RETIRE:
 153  
 //              GWT.runAsync(new RunAsyncGetView() {
 154  
 //                  @Override
 155  
 //                  public void onSuccess() {
 156  0
                       callback.exec(getCourseAdminRetireController());
 157  
 //                  }
 158  
 //              });
 159  0
               break;
 160  
 
 161  
             case VIEW_COURSE:
 162  
 //                GWT.runAsync(new RunAsyncGetView() {
 163  
 //                    @Override
 164  
 //                    public void onSuccess() {
 165  0
                         callback.exec(getViewCourseController());
 166  
 //                    }
 167  
 //                });
 168  0
                 break;
 169  
             case PROGRAM_PROPOSAL:
 170  
 //                GWT.runAsync(new RunAsyncGetView() {
 171  
 //                    @Override
 172  
 //                    public void onSuccess() {
 173  0
                          if (ProgramRegistry.isCreateNew()) {
 174  0
                            ProgramRegistry.setCreateNew(false);
 175  0
                             majorManager = new MajorManager();
 176  
                          }
 177  0
                          callback.exec(majorManager.getMajorProposalController());
 178  
 //                    }
 179  
 //                });
 180  0
                 break;
 181  
              case PROGRAM_VIEW:
 182  
 //                GWT.runAsync(new RunAsyncGetView() {
 183  
 //                   @Override
 184  
 //                    public void onSuccess() {
 185  0
                         if (ProgramRegistry.isCreateNew()) {
 186  0
                             ProgramRegistry.setCreateNew(false);
 187  0
                             majorManager = new MajorManager();
 188  
                         }
 189  0
                         callback.exec(majorManager.getProgramViewController());
 190  
 //                    }
 191  
 //                });
 192  0
                 break;
 193  
             case PROGRAM_EDIT:
 194  
 //                GWT.runAsync(new RunAsyncGetView() {
 195  
 //                    @Override
 196  
 //                    public void onSuccess() {
 197  0
                             Application.getApplicationContext().setParentPath("");//Reset the parent path when navigating back
 198  0
                         if (ProgramRegistry.isCreateNew()) {
 199  0
                             ProgramRegistry.setCreateNew(false);
 200  0
                             majorManager = new MajorManager();
 201  
                         }
 202  0
                         callback.exec(majorManager.getProgramEditController());
 203  
 //                    }
 204  
 //                });
 205  0
                 break;
 206  
             case PROGRAM_SPEC_EDIT:
 207  
 //                GWT.runAsync(new RunAsyncGetView() {
 208  
 //                    @Override
 209  
 //                    public void onSuccess() {
 210  0
                         if (ProgramRegistry.isCreateNew()) {
 211  0
                             ProgramRegistry.setCreateNew(false);
 212  0
                             majorManager = new MajorManager();
 213  
                         }
 214  0
                         callback.exec(majorManager.getProgramSpecEditController());
 215  
 //                    }
 216  
 //                });
 217  0
                 break;                
 218  
             case PROGRAM_CREATE:
 219  
 //                GWT.runAsync(new RunAsyncGetView() {
 220  
 //                    @Override
 221  
 //                    public void onSuccess() {
 222  0
                         majorManager = new MajorManager();
 223  0
                         callback.exec(majorManager.getProgramEditController());
 224  
 //                    }
 225  
 //                });
 226  0
                 break;
 227  
             case PROGRAM_VERSIONS:
 228  
 //                GWT.runAsync(new RunAsyncGetView() {
 229  
 //                    @Override
 230  
 //                    public void onSuccess() {
 231  0
                         callback.exec(majorManager.getProgramVersionsController());
 232  
 //                    }
 233  
 //                });
 234  0
                 break;
 235  
             case CLU_SETS:
 236  
 //                GWT.runAsync(new RunAsyncGetView() {
 237  
 //                    @Override
 238  
 //                    public void onSuccess() {
 239  0
                         callback.exec(getCluSetsController());
 240  
 //                    }
 241  
 //                });
 242  0
                 break;
 243  
             case COURSE_CATALOG:
 244  
 //                GWT.runAsync(new RunAsyncGetView() {
 245  
 //                    @Override
 246  
 //                    public void onSuccess() {
 247  0
                         callback.exec(getBrowseCatalogController());
 248  
 //                    }
 249  
 //                });
 250  0
                 break;
 251  
             case VARIATION_VIEW:
 252  
 //                GWT.runAsync(new RunAsyncGetView() {
 253  
 //                    @Override
 254  
 //                    public void onSuccess() {
 255  
                     //Check if key data has been initialized (the program was loaded before the variation)
 256  0
                     if(majorManager.getProgramModel()!=null && majorManager.getProgramModel().getDefinition()!=null){        
 257  0
                         callback.exec(majorManager.getVariationViewController());
 258  
                     }else{
 259  
                             //If it has not yet been initialized, we need to pull some context information and 
 260  
                             //navigate to the program view which will initialize program information and then load the variation view.
 261  
                             //This is similar to the getFindMajorsWidget() in the CurriculumHomeConfigurer
 262  0
                             ViewContext viewContext = new ViewContext();
 263  0
                     viewContext.setId(tokenMap.get("docId"));
 264  0
                     viewContext.setAttribute(ProgramConstants.VARIATION_ID, tokenMap.get(ProgramConstants.VARIATION_ID));
 265  0
                     viewContext.setAttribute(ProgramConstants.TYPE, ProgramConstants.VARIATION_TYPE_KEY);
 266  0
                     viewContext.setIdType(IdType.OBJECT_ID);
 267  0
                     ProgramRegistry.setCreateNew(true);
 268  0
                     Application.navigate(AppLocations.Locations.VIEW_PROGRAM.getLocation(), viewContext);
 269  
                     }
 270  
 //                    }
 271  
 //                });
 272  0
                 break;
 273  
             case VARIATION_EDIT:
 274  
 //                GWT.runAsync(new RunAsyncGetView() {
 275  
 //                    @Override
 276  
 //                    public void onSuccess() {
 277  0
                     if(majorManager.getProgramModel()!=null && majorManager.getProgramModel().getDefinition()!=null){        
 278  0
                     callback.exec(majorManager.getVariationEditController());
 279  
                     }else{
 280  
                             //If the variation edit is refreshed, bring the user to the program screen first
 281  0
                         Application.getApplicationContext().setParentPath("");//Reset the parent path when navigating back
 282  0
                     if (ProgramRegistry.isCreateNew()) {
 283  0
                         ProgramRegistry.setCreateNew(false);
 284  0
                         majorManager = new MajorManager();
 285  
                     }
 286  0
                     callback.exec(majorManager.getProgramEditController());
 287  
                     }
 288  
 //                    }
 289  
 //                });
 290  0
                 break;
 291  
             case CORE_PROGRAM_VIEW:
 292  
 //                GWT.runAsync(new RunAsyncGetView() {
 293  
 //                    @Override
 294  
 //                    public void onSuccess() {
 295  0
                         if (ProgramRegistry.isCreateNew()) {
 296  0
                             ProgramRegistry.setCreateNew(false);
 297  0
                             coreManager = new CoreManager();
 298  
                         }
 299  0
                         callback.exec(coreManager.getViewController());
 300  
 //                    }
 301  
 //                });
 302  0
                 break;
 303  
             case CORE_PROGRAM_EDIT:
 304  
 //                GWT.runAsync(new RunAsyncGetView() {
 305  
 //                    @Override
 306  
 //                    public void onSuccess() {
 307  0
                         callback.exec(coreManager.getEditController());
 308  
 //                    }
 309  
 //                });
 310  0
                 break;
 311  
             case CORE_PROGRAM_VERSIONS:
 312  
 //                GWT.runAsync(new RunAsyncGetView() {
 313  
 //                    @Override
 314  
 //                    public void onSuccess() {
 315  0
                         callback.exec(coreManager.getProgramVersionsController());
 316  
 //                    }
 317  
 //                });
 318  0
                 break;
 319  
             case BACC_PROGRAM_VIEW:
 320  
 //                GWT.runAsync(new RunAsyncGetView() {
 321  
 //                    @Override
 322  
 //                    public void onSuccess() {
 323  0
                         if (ProgramRegistry.isCreateNew()) {
 324  0
                             ProgramRegistry.setCreateNew(false);
 325  0
                             credentialManager = new CredentialManager();
 326  
                         }
 327  0
                         callback.exec(credentialManager.getBaccViewController());
 328  
 //                    }
 329  
 //                });
 330  0
                 break;
 331  
             case BACC_PROGRAM_EDIT:
 332  
 //                GWT.runAsync(new RunAsyncGetView() {
 333  
 //                    @Override
 334  
 //                    public void onSuccess() {
 335  0
                         callback.exec(credentialManager.getBaccEditController());
 336  
 //                    }
 337  
 //                });
 338  0
                 break;
 339  
             case BACC_PROGRAM_VERSIONS:
 340  
 //                GWT.runAsync(new RunAsyncGetView() {
 341  
 //                    @Override
 342  
 //                    public void onSuccess() {
 343  0
                         callback.exec(credentialManager.getProgramVersionsController());
 344  
 //                    }
 345  
 //                });
 346  0
                 break;
 347  
             case LO_CATEGORIES:
 348  
 //                GWT.runAsync(new RunAsyncGetView() {
 349  
 //                    @Override
 350  
 //                    public void onSuccess() {
 351  0
                         callback.exec(getCategoryManagementController());
 352  
 //                    }
 353  
 //                });
 354  0
                 break;
 355  
             case DEPENDENCY_ANALYSIS:
 356  
 //                GWT.runAsync(new RunAsyncGetView() {
 357  
 //                    @Override
 358  
 //                    public void onSuccess() {
 359  0
                         callback.exec(getDependencyAnalysisController());
 360  
 //                    }
 361  
 //                });
 362  0
                 break;
 363  
             case BROWSE_PROGRAM:
 364  
 //                GWT.runAsync(new RunAsyncGetView() {
 365  
 //                    @Override
 366  
 //                    public void onSuccess() {
 367  0
                         callback.exec(getBrowseProgramController());
 368  
 //                    }
 369  
 //                });
 370  0
                 break;
 371  
             default:
 372  0
                 callback.exec(home);
 373  
         }
 374  0
     }
 375  
 
 376  
 
 377  
    protected View getCategoryManagementController() {
 378  0
         return new CategoryManagementView(this, "Learning Objective Categories", LUMViews.LO_CATEGORIES);
 379  
     }
 380  
 
 381  
     private CourseProposalController getCourseProposalController() {
 382  0
         courseProposalController = GWT.create(CourseProposalController.class);
 383  0
         return courseProposalController;
 384  
     }
 385  
 
 386  
     private CourseProposalController getCourseRetirebyProposalController(){
 387  0
             courseRetireByProposalController = GWT.create(CourseRetireByProposalController.class);
 388  0
         return courseRetireByProposalController;
 389  
     }   
 390  
     
 391  
     private CourseAdminController getCourseAdminController() {
 392  0
         courseAdminController = GWT.create(CourseAdminController.class);
 393  0
         return courseAdminController;
 394  
     }
 395  
     
 396  
     private CourseAdminWithoutVersionController getCourseAdminRetireController(){
 397  0
         courseAdminRetireController = GWT.create(CourseAdminRetireController.class);
 398  0
         return courseAdminRetireController;
 399  
     }
 400  
 
 401  
     private CourseAdminWithoutVersionController getCourseAdminWithoutVersionController(){
 402  0
         courseAdminWithoutVersionController = GWT.create(CourseAdminWithoutVersionController.class);
 403  0
         return courseAdminWithoutVersionController;
 404  
     }
 405  
     
 406  
     private LayoutController getViewCourseController() {
 407  0
         if (viewCourseController == null) {
 408  0
             viewCourseController = GWT.create(ViewCourseParentController.class);
 409  
         }
 410  0
         return this.viewCourseController;
 411  
     }
 412  
 
 413  
     private LayoutController getCluSetsController() {
 414  0
         manageCluSetsController = GWT.create(CluSetsManagementController.class);
 415  0
         return manageCluSetsController;
 416  
     }
 417  
 
 418  
     private LayoutController getBrowseCatalogController() {
 419  0
         browseCatalogController = new CatalogBrowserController(this);
 420  0
         return browseCatalogController;
 421  
     }
 422  
 
 423  
     private LayoutController getDependencyAnalysisController() {
 424  0
             dependencyAnalysisController = new DependencyAnalysisController("DependencyAnalaysis");
 425  0
         return dependencyAnalysisController;
 426  
     }
 427  
     
 428  
     private LayoutController getBrowseProgramController() {
 429  0
             browseProgramController = new BrowseProgramController("BrowseProgram");
 430  0
         return browseProgramController;
 431  
     }
 432  
     
 433  
     @Override
 434  
     protected void hideView(View view) {
 435  0
         ApplicationController.getApplicationViewContainer().clear();
 436  0
     }
 437  
 
 438  
     @Override
 439  
     protected void renderView(View view) {
 440  0
         ApplicationController.getApplicationViewContainer().add(view.asWidget());
 441  0
     }
 442  
 
 443  
     @Override
 444  
     public Enum<?> getViewEnumValue(String enumValue) {
 445  0
         return LUMViews.valueOf(enumValue);
 446  
     }
 447  
 
 448  
     @Override
 449  
     public void updateModel() {
 450  
         // No model needed here
 451  0
     }
 452  
 
 453  
     public <V extends Enum<?>> void showView(V viewType, Callback<Boolean> onReadyCallback) {
 454  0
         if (viewType == LUMViews.DEFAULT) {
 455  0
             WindowTitleUtils.setContextTitle(name);
 456  
         }
 457  0
         super.showView(viewType, onReadyCallback);
 458  0
     }
 459  
 }