Coverage Report - org.kuali.student.lum.program.client.major.MajorManager
 
Classes in this File Line Coverage Branch Coverage Complexity
MajorManager
0%
0/41
0%
0/10
1.455
 
 1  
 package org.kuali.student.lum.program.client.major;
 2  
 
 3  
 import org.kuali.student.common.ui.client.application.ViewContext;
 4  
 import org.kuali.student.common.ui.client.mvc.DataModel;
 5  
 import org.kuali.student.common.ui.client.mvc.DataModelDefinition;
 6  
 import org.kuali.student.lum.program.client.ProgramRegistry;
 7  
 import org.kuali.student.lum.program.client.ProgramUtils;
 8  
 import org.kuali.student.lum.program.client.events.ProgramViewEvent;
 9  
 import org.kuali.student.lum.program.client.major.edit.MajorEditController;
 10  
 import org.kuali.student.lum.program.client.major.view.MajorViewController;
 11  
 import org.kuali.student.lum.program.client.variation.edit.VariationEditController;
 12  
 import org.kuali.student.lum.program.client.variation.view.VariationViewController;
 13  
 import org.kuali.student.lum.program.client.versions.ProgramVersionsController;
 14  
 import org.kuali.student.lum.program.client.widgets.ProgramSideBar;
 15  
 
 16  
 import com.google.gwt.event.shared.HandlerManager;
 17  
 import com.google.gwt.user.client.Window;
 18  
 
 19  
 /**
 20  
  * @author Igor
 21  
  */
 22  
 public class MajorManager {
 23  
 
 24  
     private MajorViewController majorViewController;
 25  
 
 26  
     private MajorEditController majorEditController;
 27  
 
 28  
     private VariationViewController variationViewController;
 29  
 
 30  
     private VariationEditController variationEditController;
 31  
 
 32  
     private ProgramVersionsController programVersionsController;
 33  
 
 34  
     protected DataModel programModel;
 35  
 
 36  0
     private ViewContext viewContext = new ViewContext();
 37  
 
 38  
     private static HandlerManager eventBus;
 39  
 
 40  0
     public MajorManager() {
 41  0
         eventBus = new HandlerManager(null);
 42  0
         programModel = new DataModel();
 43  0
         ProgramRegistry.getSpecializationHandlers().clear();
 44  0
     }
 45  
 
 46  
     public MajorViewController getProgramViewController() {
 47  0
         programModel.resetRoot();
 48  0
         getMajorViewController();
 49  0
         eventBus.fireEvent(new ProgramViewEvent());
 50  0
         return majorViewController;
 51  
     }
 52  
 
 53  
     public VariationViewController getVariationViewController() {
 54  0
         DataModel variationModel = new DataModel();
 55  
 //        variationModel.setDefinition(programModel.getDefinition());
 56  0
         DataModelDefinition definition = new DataModelDefinition ();
 57  0
         definition.setMetadata (programModel.getDefinition ().getMetadata ("variations/*"));
 58  0
         variationModel.setDefinition(definition);
 59  0
         variationModel.setRoot(ProgramRegistry.getData());
 60  0
         variationViewController = new VariationViewController(variationModel, viewContext, eventBus, majorViewController);
 61  0
         return variationViewController;
 62  
     }
 63  
 
 64  
 //  private String formatMetadata (Metadata md, String fieldKey)
 65  
 //  {
 66  
 //   String msg = "metadata for fieldKey=" + fieldKey
 67  
 //                //    + "\n Name=" + md.getName ()
 68  
 //                + "\n LabelKey=" + md.getLabelKey ()
 69  
 //                + "\n defaultValuePath=" + md.getDefaultValuePath ()
 70  
 //                + "\n LookupContextPath=" + md.getLookupContextPath ()
 71  
 //                //    + "\n maskForatter="  + md.getMaskFormatter ()
 72  
 //                //    + "\n partialMaskFormatter="  + md.getPartialMaskFormatter ()
 73  
 //                + "\n dataType=" + md.getDataType ()
 74  
 //                + "\n defaultValue=" + md.getDefaultValue ()
 75  
 //                + "\n WriteAccess=" + md.getWriteAccess ()
 76  
 //                + "\n initialLookup=" + md.getInitialLookup ()
 77  
 //                + "\n additionalLookups=" + md.getAdditionalLookups ();
 78  
 //   if (md.getProperties () != null)
 79  
 //   {
 80  
 //    msg += "\n It has " + md.getProperties ().size () + " properties: \n";
 81  
 //    for (String fk : md.getProperties ().keySet ())
 82  
 //    {
 83  
 //     msg += "\n" + formatMetadata (md.getProperties ().get (fk), fk);
 84  
 //    }
 85  
 //   }
 86  
 //   return msg;
 87  
 //  }
 88  
 
 89  
 
 90  
     public VariationEditController getVariationEditController() {
 91  0
         DataModel variationModel = new DataModel();
 92  
 //        variationModel.setDefinition(programModel.getDefinition());
 93  0
         DataModelDefinition definition = new DataModelDefinition ();
 94  
         //What if the program model is not ready yet??
 95  0
         if(programModel==null||programModel.getDefinition()==null){
 96  0
                 Window.alert("Debug: null programModel or definition (MajorManager.getVariationEditController()");
 97  
         }
 98  0
         definition.setMetadata(programModel.getDefinition().getMetadata("variations/*"));
 99  
 //        KSErrorDialog.show (new NullPointerException
 100  
 //     ("metada for: "
 101  
 //     +  formatMetadata (definition.getMetadata (), "variations/*")));
 102  0
         variationModel.setDefinition(definition);
 103  0
         variationModel.setRoot(ProgramRegistry.getData());
 104  0
         ProgramUtils.unregisterUnusedHandlers(eventBus);
 105  0
         variationEditController = new VariationEditController(variationModel, viewContext, eventBus, majorEditController);
 106  0
         return variationEditController;
 107  
     }
 108  
 
 109  
     public MajorEditController getProgramEditController() {
 110  0
         programModel.resetRoot();
 111  0
         return getMajorEditController();
 112  
     }
 113  
     
 114  
     public MajorEditController getProgramSpecEditController() {
 115  0
         return getMajorEditController();
 116  
     }
 117  
     
 118  
     public ProgramVersionsController getProgramVersionsController() {
 119  0
         if (programVersionsController == null) {
 120  0
             programVersionsController = new ProgramVersionsController(programModel, ProgramSideBar.Type.MAJOR, viewContext, eventBus);
 121  
         }
 122  0
         return programVersionsController;
 123  
     }
 124  
 
 125  
     public static HandlerManager getEventBus() {
 126  0
         return eventBus;
 127  
     }
 128  
 
 129  
     private MajorEditController getMajorEditController() {
 130  0
         if (majorEditController == null) {
 131  0
             majorEditController = new MajorEditController(programModel, viewContext, eventBus);
 132  
         }
 133  0
         return majorEditController;
 134  
     }
 135  
 
 136  
     private MajorViewController getMajorViewController() {
 137  0
         if (majorViewController == null) {
 138  0
             majorViewController = new MajorViewController(programModel, viewContext, eventBus);
 139  
         }
 140  0
         return majorViewController;
 141  
     }
 142  
 
 143  
         public DataModel getProgramModel() {
 144  0
                 return programModel;
 145  
         }
 146  
 }