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