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