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