Coverage Report - org.kuali.student.lum.lu.ui.main.client.controllers.CurriculumHomeController
 
Classes in this File Line Coverage Branch Coverage Complexity
CurriculumHomeController
0%
0/84
0%
0/26
1.778
CurriculumHomeController$1
0%
0/3
N/A
1.778
CurriculumHomeController$10
0%
0/3
N/A
1.778
CurriculumHomeController$11
0%
0/3
N/A
1.778
CurriculumHomeController$12
0%
0/6
0%
0/2
1.778
CurriculumHomeController$13
0%
0/3
N/A
1.778
CurriculumHomeController$14
0%
0/3
N/A
1.778
CurriculumHomeController$15
0%
0/6
0%
0/2
1.778
CurriculumHomeController$16
0%
0/3
N/A
1.778
CurriculumHomeController$17
0%
0/3
N/A
1.778
CurriculumHomeController$18
0%
0/3
N/A
1.778
CurriculumHomeController$19
0%
0/3
N/A
1.778
CurriculumHomeController$2
0%
0/3
N/A
1.778
CurriculumHomeController$20
0%
0/3
N/A
1.778
CurriculumHomeController$21
0%
0/1
N/A
1.778
CurriculumHomeController$3
0%
0/6
0%
0/2
1.778
CurriculumHomeController$4
0%
0/7
0%
0/2
1.778
CurriculumHomeController$5
0%
0/6
0%
0/2
1.778
CurriculumHomeController$6
0%
0/4
N/A
1.778
CurriculumHomeController$7
0%
0/3
N/A
1.778
CurriculumHomeController$8
0%
0/3
N/A
1.778
CurriculumHomeController$9
0%
0/3
N/A
1.778
CurriculumHomeController$RunAsyncGetView
0%
0/3
N/A
1.778
 
 1  
 package org.kuali.student.lum.lu.ui.main.client.controllers;
 2  
 
 3  
 import org.kuali.student.common.ui.client.application.Application;
 4  
 import org.kuali.student.common.ui.client.configurable.mvc.LayoutController;
 5  
 import org.kuali.student.common.ui.client.mvc.Callback;
 6  
 import org.kuali.student.common.ui.client.mvc.Controller;
 7  
 import org.kuali.student.common.ui.client.mvc.View;
 8  
 import org.kuali.student.common.ui.client.util.WindowTitleUtils;
 9  
 import org.kuali.student.common.ui.client.widgets.field.layout.element.SpanPanel;
 10  
 import org.kuali.student.lum.common.client.configuration.LUMViews;
 11  
 import org.kuali.student.lum.lu.ui.browseprogram.client.controllers.BrowseProgramController;
 12  
 import org.kuali.student.lum.lu.ui.course.client.controllers.CourseProposalController;
 13  
 import org.kuali.student.lum.lu.ui.course.client.controllers.ViewCourseParentController;
 14  
 import org.kuali.student.lum.lu.ui.course.client.views.CategoryManagementView;
 15  
 import org.kuali.student.lum.lu.ui.course.client.views.CurriculumHomeView;
 16  
 import org.kuali.student.lum.lu.ui.dependency.client.controllers.DependencyAnalysisController;
 17  
 import org.kuali.student.lum.lu.ui.tools.client.configuration.CatalogBrowserController;
 18  
 import org.kuali.student.lum.lu.ui.tools.client.configuration.CluSetsManagementController;
 19  
 import org.kuali.student.lum.program.client.ProgramRegistry;
 20  
 import org.kuali.student.lum.program.client.core.CoreManager;
 21  
 import org.kuali.student.lum.program.client.credential.CredentialManager;
 22  
 import org.kuali.student.lum.program.client.major.MajorManager;
 23  
 
 24  
 import com.google.gwt.core.client.GWT;
 25  
 import com.google.gwt.core.client.RunAsyncCallback;
 26  
 import com.google.gwt.user.client.Window;
 27  
 
 28  
 /**
 29  
  * Curriculum home controller which controls the main LayoutController views of the lum application.  The
 30  
  * default view of this controller is the Curriculum Home Landing page.  The following views are views within
 31  
  * this controller's scope:<br>
 32  
  *                 COURSE_PROPOSAL<br>
 33  
         VIEW_COURSE<br>
 34  
         PROGRAM_VIEW<br>
 35  
         PROGRAM_EDIT<br>
 36  
         PROGRAM_CREATE<br>
 37  
         PROGRAM_VERSIONS<br>
 38  
         CLU_SETS<br>
 39  
         VARIATION_VIEW<br>
 40  
         VARIATION_EDIT<br>
 41  
         COURSE_CATALOG<br>
 42  
         LO_CATEGORIES<br>
 43  
         BACC_PROGRAM_VIEW<br>
 44  
         BACC_PROGRAM_EDIT<br>
 45  
         BACC_PROGRAM_VERSIONS<br>
 46  
         CORE_PROGRAM_VIEW<br>
 47  
         CORE_PROGRAM_EDIT<br>
 48  
         CORE_PROGRAM_VERSIONS<br>
 49  
  * These views can be accessed through links and searches provided by the CurriculumHomeView (the default view).
 50  
  * 
 51  
  * @author Kuali Student Team
 52  
  * @see CurriculumHomeView
 53  
  */
 54  0
 public class CurriculumHomeController extends LayoutController {
 55  
 
 56  
     private CurriculumHomeView home;
 57  0
     private final SpanPanel panel = new SpanPanel();
 58  
 
 59  
     private CourseProposalController courseProposalController;
 60  
     private LayoutController viewCourseController;
 61  
     private LayoutController manageCluSetsController;
 62  
     private LayoutController browseCatalogController;
 63  
     private LayoutController dependencyAnalysisController;
 64  
     private LayoutController browseProgramController;
 65  0
     private MajorManager majorManager = new MajorManager();
 66  0
     private CredentialManager credentialManager = new CredentialManager();
 67  0
     private CoreManager coreManager = new CoreManager();
 68  
 
 69  0
     private abstract class RunAsyncGetView implements RunAsyncCallback {
 70  
         public void onFailure(Throwable reason) {
 71  0
             Window.alert("Download failed.  Please try again.");
 72  0
         }
 73  
     }
 74  
 
 75  
     public CurriculumHomeController(Controller controller, String name, Enum<?> viewType) {
 76  0
         super();
 77  0
         super.setController(controller);
 78  0
         super.setName(name);
 79  0
         super.setViewEnum(viewType);
 80  0
         this.setDefaultView(LUMViews.DEFAULT);
 81  0
         this.initWidget(panel);
 82  0
         setupDefaultView();
 83  0
     }
 84  
 
 85  
     private void setupDefaultView() {
 86  0
         home = new CurriculumHomeView(this, LUMViews.DEFAULT);
 87  0
     }
 88  
 
 89  
     @Override
 90  
     public <V extends Enum<?>> void getView(V viewType, final Callback<View> callback) {
 91  
         //this is done so the views can have delayed loading
 92  
 
 93  0
         switch ((LUMViews) viewType) {
 94  
             case DEFAULT:
 95  0
                 callback.exec(home);
 96  0
                 break;
 97  
             case COURSE_PROPOSAL:
 98  0
                 GWT.runAsync(new RunAsyncGetView() {
 99  
                     @Override
 100  
                     public void onSuccess() {
 101  0
                         callback.exec(getCourseProposalController());
 102  0
                     }
 103  
                 });
 104  0
                 break;
 105  
             case VIEW_COURSE:
 106  0
                 GWT.runAsync(new RunAsyncGetView() {
 107  
                     @Override
 108  
                     public void onSuccess() {
 109  0
                         callback.exec(getViewCourseController());
 110  0
                     }
 111  
                 });
 112  0
                 break;
 113  
             case PROGRAM_VIEW:
 114  0
                 GWT.runAsync(new RunAsyncGetView() {
 115  
                     @Override
 116  
                     public void onSuccess() {
 117  0
                         if (ProgramRegistry.isCreateNew()) {
 118  0
                             ProgramRegistry.setCreateNew(false);
 119  0
                             majorManager = new MajorManager();
 120  
                         }
 121  0
                         callback.exec(majorManager.getProgramViewController());
 122  0
                     }
 123  
                 });
 124  0
                 break;
 125  
             case PROGRAM_EDIT:
 126  0
                 GWT.runAsync(new RunAsyncGetView() {
 127  
                     @Override
 128  
                     public void onSuccess() {
 129  0
                             Application.getApplicationContext().setParentPath("");//Reset the parent path when navigating back
 130  0
                         if (ProgramRegistry.isCreateNew()) {
 131  0
                             ProgramRegistry.setCreateNew(false);
 132  0
                             majorManager = new MajorManager();
 133  
                         }
 134  0
                         callback.exec(majorManager.getProgramEditController());
 135  0
                     }
 136  
                 });
 137  0
                 break;
 138  
             case PROGRAM_SPEC_EDIT:
 139  0
                 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.getProgramSpecEditController());
 147  0
                     }
 148  
                 });
 149  0
                 break;                
 150  
             case PROGRAM_CREATE:
 151  0
                 GWT.runAsync(new RunAsyncGetView() {
 152  
                     @Override
 153  
                     public void onSuccess() {
 154  0
                         majorManager = new MajorManager();
 155  0
                         callback.exec(majorManager.getProgramEditController());
 156  0
                     }
 157  
                 });
 158  0
                 break;
 159  
             case PROGRAM_VERSIONS:
 160  0
                 GWT.runAsync(new RunAsyncGetView() {
 161  
                     @Override
 162  
                     public void onSuccess() {
 163  0
                         callback.exec(majorManager.getProgramVersionsController());
 164  0
                     }
 165  
                 });
 166  0
                 break;
 167  
             case CLU_SETS:
 168  0
                 GWT.runAsync(new RunAsyncGetView() {
 169  
                     @Override
 170  
                     public void onSuccess() {
 171  0
                         callback.exec(getCluSetsController());
 172  0
                     }
 173  
                 });
 174  0
                 break;
 175  
             case COURSE_CATALOG:
 176  0
                 GWT.runAsync(new RunAsyncGetView() {
 177  
                     @Override
 178  
                     public void onSuccess() {
 179  0
                         callback.exec(getBrowseCatalogController());
 180  0
                     }
 181  
                 });
 182  0
                 break;
 183  
             case VARIATION_VIEW:
 184  0
                 GWT.runAsync(new RunAsyncGetView() {
 185  
                     @Override
 186  
                     public void onSuccess() {
 187  0
                         callback.exec(majorManager.getVariationViewController());
 188  0
                     }
 189  
                 });
 190  0
                 break;
 191  
             case VARIATION_EDIT:
 192  0
                 GWT.runAsync(new RunAsyncGetView() {
 193  
                     @Override
 194  
                     public void onSuccess() {
 195  0
                         callback.exec(majorManager.getVariationEditController());
 196  0
                     }
 197  
                 });
 198  0
                 break;
 199  
             case CORE_PROGRAM_VIEW:
 200  0
                 GWT.runAsync(new RunAsyncGetView() {
 201  
                     @Override
 202  
                     public void onSuccess() {
 203  0
                         if (ProgramRegistry.isCreateNew()) {
 204  0
                             ProgramRegistry.setCreateNew(false);
 205  0
                             coreManager = new CoreManager();
 206  
                         }
 207  0
                         callback.exec(coreManager.getViewController());
 208  0
                     }
 209  
                 });
 210  0
                 break;
 211  
             case CORE_PROGRAM_EDIT:
 212  0
                 GWT.runAsync(new RunAsyncGetView() {
 213  
                     @Override
 214  
                     public void onSuccess() {
 215  0
                         callback.exec(coreManager.getEditController());
 216  0
                     }
 217  
                 });
 218  0
                 break;
 219  
             case CORE_PROGRAM_VERSIONS:
 220  0
                 GWT.runAsync(new RunAsyncGetView() {
 221  
                     @Override
 222  
                     public void onSuccess() {
 223  0
                         callback.exec(coreManager.getProgramVersionsController());
 224  0
                     }
 225  
                 });
 226  0
                 break;
 227  
             case BACC_PROGRAM_VIEW:
 228  0
                 GWT.runAsync(new RunAsyncGetView() {
 229  
                     @Override
 230  
                     public void onSuccess() {
 231  0
                         if (ProgramRegistry.isCreateNew()) {
 232  0
                             ProgramRegistry.setCreateNew(false);
 233  0
                             credentialManager = new CredentialManager();
 234  
                         }
 235  0
                         callback.exec(credentialManager.getBaccViewController());
 236  0
                     }
 237  
                 });
 238  0
                 break;
 239  
             case BACC_PROGRAM_EDIT:
 240  0
                 GWT.runAsync(new RunAsyncGetView() {
 241  
                     @Override
 242  
                     public void onSuccess() {
 243  0
                         callback.exec(credentialManager.getBaccEditController());
 244  0
                     }
 245  
                 });
 246  0
                 break;
 247  
             case BACC_PROGRAM_VERSIONS:
 248  0
                 GWT.runAsync(new RunAsyncGetView() {
 249  
                     @Override
 250  
                     public void onSuccess() {
 251  0
                         callback.exec(credentialManager.getProgramVersionsController());
 252  0
                     }
 253  
                 });
 254  0
                 break;
 255  
             case LO_CATEGORIES:
 256  0
                 GWT.runAsync(new RunAsyncGetView() {
 257  
                     @Override
 258  
                     public void onSuccess() {
 259  0
                         callback.exec(getCategoryManagementController());
 260  0
                     }
 261  
                 });
 262  0
                 break;
 263  
             case DEPENDENCY_ANALYSIS:
 264  0
                 GWT.runAsync(new RunAsyncGetView() {
 265  
                     @Override
 266  
                     public void onSuccess() {
 267  0
                         callback.exec(getDependencyAnalysisController());
 268  0
                     }
 269  
                 });
 270  0
                 break;
 271  
             case BROWSE_PROGRAM:
 272  0
                 GWT.runAsync(new RunAsyncGetView() {
 273  
                     @Override
 274  
                     public void onSuccess() {
 275  0
                         callback.exec(getBrowseProgramController());
 276  0
                     }
 277  
                 });
 278  0
                 break;
 279  
             default:
 280  0
                 callback.exec(home);
 281  
         }
 282  0
     }
 283  
 
 284  
 
 285  
     private View getCategoryManagementController() {
 286  0
         return new CategoryManagementView(this, "Learning Objective Categories", LUMViews.LO_CATEGORIES);
 287  
     }
 288  
 
 289  
     private CourseProposalController getCourseProposalController() {
 290  0
         courseProposalController = new CourseProposalController();
 291  0
         return courseProposalController;
 292  
     }
 293  
 
 294  
     private LayoutController getViewCourseController() {
 295  0
         if (viewCourseController == null) {
 296  0
             viewCourseController = new ViewCourseParentController();
 297  
         }
 298  0
         return this.viewCourseController;
 299  
     }
 300  
 
 301  
     private LayoutController getCluSetsController() {
 302  0
         manageCluSetsController = new CluSetsManagementController();
 303  0
         return manageCluSetsController;
 304  
     }
 305  
 
 306  
     private LayoutController getBrowseCatalogController() {
 307  0
         browseCatalogController = new CatalogBrowserController(this);
 308  0
         return browseCatalogController;
 309  
     }
 310  
 
 311  
     private LayoutController getDependencyAnalysisController() {
 312  0
             dependencyAnalysisController = new DependencyAnalysisController("DependencyAnalaysis");
 313  0
         return dependencyAnalysisController;
 314  
     }
 315  
     
 316  
     private LayoutController getBrowseProgramController() {
 317  0
             browseProgramController = new BrowseProgramController("BrowseProgram");
 318  0
         return browseProgramController;
 319  
     }
 320  
     
 321  
     @Override
 322  
     protected void hideView(View view) {
 323  0
         ApplicationController.getApplicationViewContainer().clear();
 324  0
     }
 325  
 
 326  
     @Override
 327  
     protected void renderView(View view) {
 328  0
         ApplicationController.getApplicationViewContainer().add(view.asWidget());
 329  0
     }
 330  
 
 331  
     @Override
 332  
     public Enum<?> getViewEnumValue(String enumValue) {
 333  0
         return LUMViews.valueOf(enumValue);
 334  
     }
 335  
 
 336  
     @Override
 337  
     public void updateModel() {
 338  
         // No model needed here
 339  0
     }
 340  
 
 341  
     public <V extends Enum<?>> void showView(V viewType, Callback<Boolean> onReadyCallback) {
 342  0
         if (viewType == LUMViews.DEFAULT) {
 343  0
             WindowTitleUtils.setContextTitle(name);
 344  
         }
 345  0
         super.showView(viewType, onReadyCallback);
 346  0
     }
 347  
 }