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