Coverage Report - org.kuali.student.lum.program.client.major.MajorManager
 
Classes in this File Line Coverage Branch Coverage Complexity
MajorManager
0%
0/38
0%
0/6
1.3
 
 1  
 package org.kuali.student.lum.program.client.major;
 2  
 
 3  
 import com.google.gwt.event.shared.HandlerManager;
 4  
 import org.kuali.student.common.ui.client.application.ViewContext;
 5  
 import org.kuali.student.common.ui.client.mvc.DataModel;
 6  
 import org.kuali.student.common.ui.client.mvc.DataModelDefinition;
 7  
 import org.kuali.student.common.ui.client.widgets.KSErrorDialog;
 8  
 import org.kuali.student.core.assembly.data.Metadata;
 9  
 import org.kuali.student.lum.program.client.ProgramRegistry;
 10  
 import org.kuali.student.lum.program.client.ProgramUtils;
 11  
 import org.kuali.student.lum.program.client.events.ProgramViewEvent;
 12  
 import org.kuali.student.lum.program.client.major.edit.MajorEditController;
 13  
 import org.kuali.student.lum.program.client.major.view.MajorViewController;
 14  
 import org.kuali.student.lum.program.client.variation.edit.VariationEditController;
 15  
 import org.kuali.student.lum.program.client.variation.view.VariationViewController;
 16  
 import org.kuali.student.lum.program.client.versions.ProgramVersionsController;
 17  
 import org.kuali.student.lum.program.client.widgets.ProgramSideBar;
 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  0
         definition.setMetadata (programModel.getDefinition ().getMetadata ("variations/*"));
 95  
 //        KSErrorDialog.show (new NullPointerException
 96  
 //     ("metada for: "
 97  
 //     +  formatMetadata (definition.getMetadata (), "variations/*")));
 98  0
         variationModel.setDefinition(definition);
 99  0
         variationModel.setRoot(ProgramRegistry.getData());
 100  0
         ProgramUtils.unregisterUnusedHandlers(eventBus);
 101  0
         variationEditController = new VariationEditController(variationModel, viewContext, eventBus, majorEditController);
 102  0
         return variationEditController;
 103  
     }
 104  
 
 105  
     public MajorEditController getProgramEditController() {
 106  0
         programModel.resetRoot();
 107  0
         return getMajorEditController();
 108  
     }
 109  
     
 110  
     public MajorEditController getProgramSpecEditController() {
 111  0
         return getMajorEditController();
 112  
     }
 113  
     
 114  
     public ProgramVersionsController getProgramVersionsController() {
 115  0
         if (programVersionsController == null) {
 116  0
             programVersionsController = new ProgramVersionsController(programModel, ProgramSideBar.Type.MAJOR, viewContext, eventBus);
 117  
         }
 118  0
         return programVersionsController;
 119  
     }
 120  
 
 121  
     public static HandlerManager getEventBus() {
 122  0
         return eventBus;
 123  
     }
 124  
 
 125  
     private MajorEditController getMajorEditController() {
 126  0
         if (majorEditController == null) {
 127  0
             majorEditController = new MajorEditController(programModel, viewContext, eventBus);
 128  
         }
 129  0
         return majorEditController;
 130  
     }
 131  
 
 132  
     private MajorViewController getMajorViewController() {
 133  0
         if (majorViewController == null) {
 134  0
             majorViewController = new MajorViewController(programModel, viewContext, eventBus);
 135  
         }
 136  0
         return majorViewController;
 137  
     }
 138  
 }