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