Coverage Report - org.kuali.student.lum.program.client.major.view.MajorKeyProgramInfoViewConfiguration
 
Classes in this File Line Coverage Branch Coverage Complexity
MajorKeyProgramInfoViewConfiguration
0%
0/131
0%
0/12
1.273
MajorKeyProgramInfoViewConfiguration$1
0%
0/6
N/A
1.273
 
 1  
 package org.kuali.student.lum.program.client.major.view;
 2  
 
 3  
 import org.kuali.student.common.assembly.data.Metadata;
 4  
 import org.kuali.student.common.assembly.data.QueryPath;
 5  
 import org.kuali.student.common.ui.client.configurable.mvc.Configurer;
 6  
 import org.kuali.student.common.ui.client.configurable.mvc.FieldDescriptor;
 7  
 import org.kuali.student.common.ui.client.configurable.mvc.FieldDescriptorReadOnly;
 8  
 import org.kuali.student.common.ui.client.configurable.mvc.SectionTitle;
 9  
 import org.kuali.student.common.ui.client.configurable.mvc.binding.ListToTextBinding;
 10  
 import org.kuali.student.common.ui.client.configurable.mvc.binding.ModelWidgetBinding;
 11  
 import org.kuali.student.common.ui.client.configurable.mvc.sections.HorizontalSection;
 12  
 import org.kuali.student.common.ui.client.configurable.mvc.sections.TableSection;
 13  
 import org.kuali.student.common.ui.client.configurable.mvc.sections.VerticalSection;
 14  
 import org.kuali.student.common.ui.client.configurable.mvc.views.VerticalSectionView;
 15  
 import org.kuali.student.common.ui.client.mvc.Controller;
 16  
 import org.kuali.student.common.ui.client.mvc.DataModel;
 17  
 import org.kuali.student.common.ui.client.mvc.ModelRequestCallback;
 18  
 import org.kuali.student.common.ui.client.widgets.field.layout.element.MessageKeyInfo;
 19  
 import org.kuali.student.common.ui.client.widgets.table.summary.SummaryTableFieldBlock;
 20  
 import org.kuali.student.common.ui.client.widgets.table.summary.SummaryTableFieldRow;
 21  
 import org.kuali.student.common.ui.client.widgets.table.summary.SummaryTableSection;
 22  
 import org.kuali.student.core.workflow.ui.client.widgets.WorkflowUtilities;
 23  
 import org.kuali.student.lum.common.client.configuration.AbstractSectionConfiguration;
 24  
 import org.kuali.student.lum.program.client.ProgramConstants;
 25  
 import org.kuali.student.lum.program.client.ProgramMsgConstants;
 26  
 import org.kuali.student.lum.program.client.ProgramSections;
 27  
 import org.kuali.student.lum.program.client.major.MajorEditableHeader;
 28  
 import org.kuali.student.lum.program.client.major.edit.MajorEditController;
 29  
 import org.kuali.student.lum.program.client.major.proposal.MajorProposalController;
 30  
 
 31  
 import com.google.gwt.user.client.ui.Widget;
 32  
 
 33  
 /**
 34  
  * @author Igor
 35  
  */
 36  0
 public class MajorKeyProgramInfoViewConfiguration extends AbstractSectionConfiguration {
 37  
 
 38  0
         private Controller controller = null;
 39  
 
 40  
     public static MajorKeyProgramInfoViewConfiguration create(Configurer configurer) {
 41  0
         return new MajorKeyProgramInfoViewConfiguration(configurer);
 42  
     }
 43  
 
 44  
     public static MajorKeyProgramInfoViewConfiguration createSpecial(Configurer configurer, Controller controller) {
 45  0
         return new MajorKeyProgramInfoViewConfiguration(configurer, controller);
 46  
     }
 47  
 
 48  0
     private MajorKeyProgramInfoViewConfiguration(Configurer configurer) {
 49  0
         this.setConfigurer(configurer);
 50  0
         String title = getLabel(ProgramMsgConstants.PROGRAM_MENU_SECTIONS_PROGRAMINFORMATION);
 51  0
         rootSection = new VerticalSectionView(ProgramSections.PROGRAM_DETAILS_VIEW, title, ProgramConstants.PROGRAM_MODEL_ID);
 52  0
         rootSection.addStyleName("programInformationView");
 53  0
     }
 54  
 
 55  0
     private MajorKeyProgramInfoViewConfiguration(Configurer configurer, Controller controller) {
 56  0
         this.setConfigurer(configurer);
 57  0
         String title = getLabel(ProgramMsgConstants.PROGRAM_MENU_SECTIONS_PROGRAMINFORMATION);
 58  0
         rootSection = new VerticalSectionView(ProgramSections.PROGRAM_DETAILS_VIEW, title, ProgramConstants.PROGRAM_MODEL_ID, 
 59  
                 new MajorEditableHeader(title, ProgramSections.PROGRAM_DETAILS_EDIT));
 60  0
         rootSection.addStyleName("programInformationView");
 61  0
         this.controller = controller;
 62  0
     }
 63  
 
 64  
     @Override
 65  
     protected void buildLayout() {
 66  0
             if (controller instanceof MajorProposalController || controller instanceof MajorEditController) 
 67  
             {
 68  0
             rootSection.addSection(createIdentifyingDetailsSectionEdit());                    
 69  0
             rootSection.addSection(createProgramTitleSectionEdit());                    
 70  0
             rootSection.addSection(createDatesSectionEdit());                    
 71  0
             rootSection.addSection(createOtherInformationSectionEdit());                    
 72  
             } else
 73  
             {
 74  0
                        HorizontalSection section = new HorizontalSection();
 75  0
                        section.addSection(createIdentifyingDetailsSection());
 76  0
                        section.addSection(createProgramTitleSection());
 77  0
                        section.nextRow();
 78  0
                        section.addSection(createDatesSection());
 79  0
                        section.addSection(createOtherInformationSection());
 80  0
                        rootSection.addSection(section);
 81  
             }
 82  0
     }
 83  
 
 84  
     private TableSection createIdentifyingDetailsSection() {
 85  0
         TableSection section = new TableSection(SectionTitle.generateH4Title(getLabel(ProgramMsgConstants.PROGRAMINFORMATION_IDENTIFYINGDETAILS)));
 86  0
         configurer.addReadOnlyField(section, ProgramConstants.CODE, generateMessageInfo(ProgramMsgConstants.PROGRAMINFORMATION_CODE));
 87  0
         configurer.addReadOnlyField(section, ProgramConstants.CREDENTIAL_PROGRAM_LEVEL, generateMessageInfo(ProgramMsgConstants.PROGRAMINFORMATION_LEVEL));
 88  0
         configurer.addReadOnlyField(section, ProgramConstants.CREDENTIAL_PROGRAM_TYPE_NAME, generateMessageInfo(ProgramMsgConstants.PROGRAMINFORMATION_CREDENTIALPROGRAM));
 89  0
         configurer.addReadOnlyField(section, ProgramConstants.PROGRAM_CLASSIFICATION, generateMessageInfo(ProgramMsgConstants.PROGRAMINFORMATION_CLASSIFICATION));
 90  0
         configurer.addReadOnlyField(section, ProgramConstants.DEGREE_TYPE, generateMessageInfo(ProgramMsgConstants.PROGRAMINFORMATION_DEGREETYPE));
 91  0
         return section;
 92  
     }
 93  
 
 94  
     private TableSection createProgramTitleSection() {
 95  0
         TableSection section = new TableSection(SectionTitle.generateH4Title(getLabel(ProgramMsgConstants.PROGRAMINFORMATION_PROGRAMTITLE)));
 96  0
         configurer.addReadOnlyField(section, ProgramConstants.LONG_TITLE, generateMessageInfo(ProgramMsgConstants.PROGRAMINFORMATION_TITLEFULL));
 97  0
         configurer.addReadOnlyField(section, ProgramConstants.SHORT_TITLE, generateMessageInfo(ProgramMsgConstants.PROGRAMINFORMATION_TITLESHORT));
 98  0
         configurer.addReadOnlyField(section, ProgramConstants.TRANSCRIPT, generateMessageInfo(ProgramMsgConstants.PROGRAMINFORMATION_TITLETRANSCRIPT));
 99  0
         configurer.addReadOnlyField(section, ProgramConstants.DIPLOMA, generateMessageInfo(ProgramMsgConstants.PROGRAMINFORMATION_TITLEDIPLOMA));
 100  0
         return section;
 101  
     }
 102  
 
 103  
     private TableSection createDatesSection() {
 104  0
         TableSection section = new TableSection(SectionTitle.generateH4Title(getLabel(ProgramMsgConstants.PROGRAMINFORMATION_DATES)));
 105  
         //Add this field and hide it so it is available for cross field validation 
 106  0
         FieldDescriptor fd = configurer.addField(section,ProgramConstants.PREV_START_TERM, generateMessageInfo(ProgramMsgConstants.MAJORDISCIPLINE_PREVSTARTTERM));
 107  0
         fd.getFieldWidget().setVisible(false);
 108  0
         fd.hideLabel();
 109  0
         configurer.addReadOnlyField(section, ProgramConstants.START_TERM, generateMessageInfo(ProgramMsgConstants.PROGRAMINFORMATION_STARTTERM));
 110  0
         configurer.addReadOnlyField(section, ProgramConstants.END_INSTITUTIONAL_ADMIT_TERM, generateMessageInfo(ProgramMsgConstants.PROGRAMINFORMATION_ADMITTERM));
 111  0
         configurer.addReadOnlyField(section, ProgramConstants.END_PROGRAM_ENTRY_TERM, generateMessageInfo(ProgramMsgConstants.PROGRAMINFORMATION_ENTRYTERM));
 112  0
         configurer.addReadOnlyField(section, ProgramConstants.END_PROGRAM_ENROLL_TERM, generateMessageInfo(ProgramMsgConstants.PROGRAMINFORMATION_ENROLLTERM));
 113  0
         configurer.addReadOnlyField(section, ProgramConstants.PROGRAM_APPROVAL_DATE, generateMessageInfo(ProgramMsgConstants.PROGRAMINFORMATION_APPROVALDATE));
 114  0
         return section;
 115  
     }
 116  
 
 117  
     private TableSection createOtherInformationSection() {
 118  0
         TableSection section = new TableSection(SectionTitle.generateH4Title(getLabel(ProgramMsgConstants.PROGRAMINFORMATION_OTHERINFORMATION)));
 119  0
         configurer.addReadOnlyField(section, ProgramConstants.LOCATION, generateMessageInfo(ProgramMsgConstants.PROGRAMINFORMATION_LOCATION));
 120  0
         FieldDescriptor fd = configurer.addReadOnlyField(section, ProgramConstants.ACCREDITING_AGENCY, generateMessageInfo(ProgramMsgConstants.PROGRAMINFORMATION_ACCREDITATION));
 121  0
         fd.setWidgetBinding(new ListToTextBinding(ProgramConstants.ACCREDITING_AGENCY_ORG_ID_TRANSLATION));
 122  0
         configurer.addReadOnlyField(section, ProgramConstants.CIP_2000, generateMessageInfo(ProgramMsgConstants.PROGRAMINFORMATION_CIP2000));
 123  0
         configurer.addReadOnlyField(section, ProgramConstants.CIP_2010, generateMessageInfo(ProgramMsgConstants.PROGRAMINFORMATION_CIP2010));
 124  0
         configurer.addReadOnlyField(section, ProgramConstants.HEGIS_CODE, generateMessageInfo(ProgramMsgConstants.PROGRAMINFORMATION_HEGIS));
 125  0
         configurer.addReadOnlyField(section, ProgramConstants.CREDENTIAL_PROGRAM_INSTITUTION_ID, generateMessageInfo(ProgramMsgConstants.PROGRAMINFORMATION_INSTITUTION));
 126  0
         return section;
 127  
     }
 128  
 
 129  
     public VerticalSection createActivateProgramSection(){
 130  0
         final VerticalSection section = new VerticalSection(SectionTitle.generateH2Title(getLabel(ProgramMsgConstants.PROGRAMINFORMATION_ACTIVATEPROGRAM)));
 131  0
         section.setInstructions("<br>" + getLabel(ProgramMsgConstants.PROGRAMINFORMATION_ACTIVATEINSTRUCTIONS) + "<br><br>");
 132  0
         controller.requestModel(new ModelRequestCallback<DataModel>(){
 133  
                         public void onModelReady(final DataModel model) {
 134  
                                 //Add previous end dates and update cross constraints
 135  0
                                 WorkflowUtilities.updateCrossField(configurer.addField(section, "proposal/"+ProgramConstants.PREV_END_PROGRAM_ENTRY_TERM, generateMessageInfo(ProgramMsgConstants.PROGRAMINFORMATION_ENTRYTERM)), model);
 136  0
                                 WorkflowUtilities.updateCrossField(configurer.addField(section, "proposal/"+ProgramConstants.PREV_END_PROGRAM_ENROLL_TERM, generateMessageInfo(ProgramMsgConstants.PROGRAMINFORMATION_ENROLLTERM)), model);
 137  0
                                 WorkflowUtilities.updateCrossField(configurer.addField(section, "proposal/"+ProgramConstants.PREV_END_INST_ADMIN_TERM, generateMessageInfo(ProgramMsgConstants.PROGRAMINFORMATION_ENTRYTERM)), model);
 138  0
                         }
 139  
                         public void onRequestFail(Throwable cause) {
 140  0
                         }
 141  
         });
 142  0
         return section;
 143  
     }
 144  
 
 145  
     // Side-by-side comparison (when controller is not null)  
 146  
     private SummaryTableSection createIdentifyingDetailsSectionEdit() { 
 147  0
               SummaryTableSection section = new SummaryTableSection((Controller) controller);                     
 148  0
               section.setEditable(false);
 149  0
               section.addSummaryTableFieldBlock(createIdentifyingDetailsSectionBlock());
 150  
 
 151  0
         return section;
 152  
     }
 153  
 
 154  
           public SummaryTableFieldBlock createIdentifyingDetailsSectionBlock() {
 155  0
                   SummaryTableFieldBlock block = new SummaryTableFieldBlock();
 156  0
                   block.setTitle(getLabel(ProgramMsgConstants.PROGRAMINFORMATION_IDENTIFYINGDETAILS));
 157  0
                   block.addSummaryTableFieldRow(getFieldRow(ProgramConstants.CODE, generateMessageInfo(ProgramMsgConstants.PROGRAMINFORMATION_CODE)));
 158  0
                   block.addSummaryTableFieldRow(getFieldRow(ProgramConstants.CREDENTIAL_PROGRAM_LEVEL, generateMessageInfo(ProgramMsgConstants.PROGRAMINFORMATION_LEVEL)));
 159  0
                   block.addSummaryTableFieldRow(getFieldRow(ProgramConstants.CREDENTIAL_PROGRAM_TYPE_NAME, generateMessageInfo(ProgramMsgConstants.PROGRAMINFORMATION_CREDENTIALPROGRAM)));
 160  0
                   block.addSummaryTableFieldRow(getFieldRow(ProgramConstants.PROGRAM_CLASSIFICATION, generateMessageInfo(ProgramMsgConstants.PROGRAMINFORMATION_CLASSIFICATION)));
 161  0
                   block.addSummaryTableFieldRow(getFieldRow(ProgramConstants.DEGREE_TYPE, generateMessageInfo(ProgramMsgConstants.PROGRAMINFORMATION_DEGREETYPE)));
 162  
 
 163  0
                   return block;
 164  
           }
 165  
     
 166  
     private SummaryTableSection createProgramTitleSectionEdit() { 
 167  0
               SummaryTableSection section = new SummaryTableSection((Controller) controller);                     
 168  0
               section.setEditable(false);
 169  0
               section.addSummaryTableFieldBlock(createProgramTitleSectionEditBlock());
 170  
 
 171  0
         return section;
 172  
     }
 173  
 
 174  
           public SummaryTableFieldBlock createProgramTitleSectionEditBlock() {
 175  0
                   SummaryTableFieldBlock block = new SummaryTableFieldBlock();
 176  0
                   block.setTitle(getLabel(ProgramMsgConstants.PROGRAMINFORMATION_PROGRAMTITLE));
 177  0
                   block.addSummaryTableFieldRow(getFieldRow(ProgramConstants.LONG_TITLE, generateMessageInfo(ProgramMsgConstants.PROGRAMINFORMATION_TITLEFULL)));
 178  0
                   block.addSummaryTableFieldRow(getFieldRow(ProgramConstants.SHORT_TITLE, generateMessageInfo(ProgramMsgConstants.PROGRAMINFORMATION_TITLESHORT)));
 179  0
                   block.addSummaryTableFieldRow(getFieldRow(ProgramConstants.TRANSCRIPT, generateMessageInfo(ProgramMsgConstants.PROGRAMINFORMATION_TITLETRANSCRIPT)));
 180  0
                   block.addSummaryTableFieldRow(getFieldRow(ProgramConstants.DIPLOMA, generateMessageInfo(ProgramMsgConstants.PROGRAMINFORMATION_TITLEDIPLOMA)));
 181  
 
 182  0
                   return block;
 183  
           }
 184  
           
 185  
     private SummaryTableSection createDatesSectionEdit() { 
 186  0
               SummaryTableSection section = new SummaryTableSection((Controller) controller);                     
 187  0
               section.setEditable(false);
 188  0
               section.addSummaryTableFieldBlock(createDatesSectionEditBlock());
 189  
 
 190  0
         return section;
 191  
     }
 192  
 
 193  
           public SummaryTableFieldBlock createDatesSectionEditBlock() {
 194  0
                   SummaryTableFieldBlock block = new SummaryTableFieldBlock();
 195  0
                   block.setTitle(getLabel(ProgramMsgConstants.PROGRAMINFORMATION_DATES));
 196  0
                   block.addSummaryTableFieldRow(getFieldRow(ProgramConstants.START_TERM, generateMessageInfo(ProgramMsgConstants.PROGRAMINFORMATION_STARTTERM)));
 197  0
                   block.addSummaryTableFieldRow(getFieldRow(ProgramConstants.END_INSTITUTIONAL_ADMIT_TERM, generateMessageInfo(ProgramMsgConstants.PROGRAMINFORMATION_ADMITTERM)));
 198  0
                   block.addSummaryTableFieldRow(getFieldRow(ProgramConstants.END_PROGRAM_ENTRY_TERM, generateMessageInfo(ProgramMsgConstants.PROGRAMINFORMATION_ENTRYTERM)));
 199  0
                   block.addSummaryTableFieldRow(getFieldRow(ProgramConstants.END_PROGRAM_ENROLL_TERM, generateMessageInfo(ProgramMsgConstants.PROGRAMINFORMATION_ENROLLTERM)));
 200  0
                   block.addSummaryTableFieldRow(getFieldRow(ProgramConstants.PROGRAM_APPROVAL_DATE, generateMessageInfo(ProgramMsgConstants.PROGRAMINFORMATION_APPROVALDATE)));
 201  
  
 202  0
                   return block;
 203  
           }
 204  
 
 205  
     private SummaryTableSection createOtherInformationSectionEdit() { 
 206  0
               SummaryTableSection section = new SummaryTableSection((Controller) controller);                     
 207  0
               section.setEditable(false);
 208  0
               section.addSummaryTableFieldBlock(createOtherInformationSectionEditBlock());
 209  
 
 210  0
         return section;
 211  
     }
 212  
 
 213  
           public SummaryTableFieldBlock createOtherInformationSectionEditBlock() {
 214  0
                   SummaryTableFieldBlock block = new SummaryTableFieldBlock();
 215  0
                   block.setTitle(getLabel(ProgramMsgConstants.PROGRAMINFORMATION_OTHERINFORMATION));
 216  0
                   block.addSummaryTableFieldRow(getFieldRow(ProgramConstants.LOCATION, generateMessageInfo(ProgramMsgConstants.PROGRAMINFORMATION_LOCATION)));
 217  0
         block.addSummaryTableFieldRow(getFieldRow(ProgramConstants.ACCREDITING_AGENCY,
 218  
                         generateMessageInfo(ProgramMsgConstants.PROGRAMINFORMATION_ACCREDITATION), null,
 219  
                 null, null, new ListToTextBinding(ProgramConstants.ACCREDITING_AGENCY_ORG_ID_TRANSLATION), false));        
 220  0
         block.addSummaryTableFieldRow(getFieldRow(ProgramConstants.CIP_2000, generateMessageInfo(ProgramMsgConstants.PROGRAMINFORMATION_CIP2000)));
 221  0
                   block.addSummaryTableFieldRow(getFieldRow(ProgramConstants.CIP_2010, generateMessageInfo(ProgramMsgConstants.PROGRAMINFORMATION_CIP2010)));
 222  0
                   block.addSummaryTableFieldRow(getFieldRow(ProgramConstants.HEGIS_CODE, generateMessageInfo(ProgramMsgConstants.PROGRAMINFORMATION_HEGIS)));
 223  0
                   block.addSummaryTableFieldRow(getFieldRow(ProgramConstants.CREDENTIAL_PROGRAM_INSTITUTION_ID, generateMessageInfo(ProgramMsgConstants.PROGRAMINFORMATION_INSTITUTION)));
 224  
                    
 225  0
                   return block;
 226  
           }
 227  
           
 228  
           protected SummaryTableFieldRow getFieldRow(String fieldKey, MessageKeyInfo messageKey) {
 229  0
                   return getFieldRow(fieldKey, messageKey, null, null, null, null, false);
 230  
           }
 231  
      
 232  
           protected SummaryTableFieldRow getFieldRow(String fieldKey,
 233  
                           MessageKeyInfo messageKey, Widget widget, Widget widget2,
 234  
                           String parentPath, ModelWidgetBinding<?> binding, boolean optional) 
 235  
           {
 236  0
                   QueryPath path = QueryPath.concat(parentPath, fieldKey);
 237  0
                   Metadata meta = configurer.getModelDefinition().getMetadata(path);
 238  
 
 239  0
                   FieldDescriptorReadOnly fd = new FieldDescriptorReadOnly(path.toString(), messageKey, meta);
 240  0
                   if (widget != null) {
 241  0
                           fd.setFieldWidget(widget);
 242  
                   }
 243  0
                   if (binding != null) {
 244  0
                           fd.setWidgetBinding(binding);
 245  
                   }
 246  0
                   fd.setOptional(optional);
 247  
 
 248  0
                   FieldDescriptorReadOnly fd2 = new FieldDescriptorReadOnly(path.toString(), messageKey, meta);
 249  0
                   if (widget2 != null) {
 250  0
                           fd2.setFieldWidget(widget2);
 251  
                   }
 252  0
                   if (binding != null) {
 253  0
                           fd2.setWidgetBinding(binding);
 254  
                   }
 255  0
                   fd2.setOptional(optional);
 256  
 
 257  0
                   SummaryTableFieldRow fieldRow = new SummaryTableFieldRow(fd, fd2);
 258  
 
 259  0
                   return fieldRow;
 260  
           }    
 261  
 }