Coverage Report - org.kuali.student.lum.program.client.major.view.MajorKeyProgramInfoViewConfiguration
 
Classes in this File Line Coverage Branch Coverage Complexity
MajorKeyProgramInfoViewConfiguration
0%
0/132
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.FieldDescriptor;
 6  
 import org.kuali.student.common.ui.client.configurable.mvc.FieldDescriptorReadOnly;
 7  
 import org.kuali.student.common.ui.client.configurable.mvc.SectionTitle;
 8  
 import org.kuali.student.common.ui.client.configurable.mvc.binding.ListToTextBinding;
 9  
 import org.kuali.student.common.ui.client.configurable.mvc.binding.ModelWidgetBinding;
 10  
 import org.kuali.student.common.ui.client.configurable.mvc.sections.HorizontalSection;
 11  
 import org.kuali.student.common.ui.client.configurable.mvc.sections.TableSection;
 12  
 import org.kuali.student.common.ui.client.configurable.mvc.sections.VerticalSection;
 13  
 import org.kuali.student.common.ui.client.configurable.mvc.views.SectionView;
 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.ProgramSections;
 26  
 import org.kuali.student.lum.program.client.major.MajorEditableHeader;
 27  
 import org.kuali.student.lum.program.client.major.edit.MajorEditController;
 28  
 import org.kuali.student.lum.program.client.major.proposal.MajorProposalController;
 29  
 import org.kuali.student.lum.program.client.properties.ProgramProperties;
 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() {
 41  0
         MajorKeyProgramInfoViewConfiguration instance = new MajorKeyProgramInfoViewConfiguration(new VerticalSectionView(ProgramSections.PROGRAM_DETAILS_VIEW, ProgramProperties.get().program_menu_sections_programInformation(), ProgramConstants.PROGRAM_MODEL_ID));
 42  0
         return instance;
 43  
     }
 44  
 
 45  
     public static MajorKeyProgramInfoViewConfiguration createSpecial(Controller controller) {
 46  0
         MajorKeyProgramInfoViewConfiguration instance = new MajorKeyProgramInfoViewConfiguration(new VerticalSectionView(ProgramSections.PROGRAM_DETAILS_VIEW, ProgramProperties.get().program_menu_sections_programInformation(), ProgramConstants.PROGRAM_MODEL_ID, new MajorEditableHeader(ProgramProperties.get().program_menu_sections_programInformation(), ProgramSections.PROGRAM_DETAILS_EDIT)), controller);
 47  0
         return instance;
 48  
     }
 49  
 
 50  0
     private MajorKeyProgramInfoViewConfiguration(SectionView sectionView) {
 51  0
         rootSection = sectionView;
 52  0
         rootSection.addStyleName("programInformationView");
 53  0
     }
 54  
 
 55  0
     private MajorKeyProgramInfoViewConfiguration(SectionView sectionView, Controller controller) {
 56  0
         rootSection = sectionView;
 57  0
         rootSection.addStyleName("programInformationView");
 58  0
         this.controller = controller;
 59  0
     }
 60  
 
 61  
     @Override
 62  
     protected void buildLayout() {
 63  0
             if (controller instanceof MajorProposalController || controller instanceof MajorEditController) 
 64  
             {
 65  0
                     VerticalSection section = new VerticalSection();
 66  0
                     section.addSection(createIdentifyingDetailsSectionEdit());
 67  0
                     section.addSection(createProgramTitleSectionEdit());
 68  0
                     section.addSection(createDatesSectionEdit());
 69  0
                     section.addSection(createOtherInformationSectionEdit());
 70  0
             rootSection.addSection(section);                    
 71  0
             } else
 72  
             {
 73  0
                        HorizontalSection section = new HorizontalSection();
 74  0
                        section.addSection(createIdentifyingDetailsSection());
 75  0
                        section.addSection(createProgramTitleSection());
 76  0
                        section.nextRow();
 77  0
                        section.addSection(createDatesSection());
 78  0
                        section.addSection(createOtherInformationSection());
 79  0
                        rootSection.addSection(section);
 80  
             }
 81  0
     }
 82  
 
 83  
     private TableSection createIdentifyingDetailsSection() {
 84  0
         TableSection section = new TableSection(SectionTitle.generateH4Title(ProgramProperties.get().programInformation_identifyingDetails()));
 85  0
         configurer.addReadOnlyField(section, ProgramConstants.CODE, new MessageKeyInfo(ProgramProperties.get().programInformation_code()));
 86  0
         configurer.addReadOnlyField(section, ProgramConstants.CREDENTIAL_PROGRAM_LEVEL, new MessageKeyInfo(ProgramProperties.get().programInformation_level()));
 87  0
         configurer.addReadOnlyField(section, ProgramConstants.CREDENTIAL_PROGRAM_TYPE_NAME, new MessageKeyInfo(ProgramProperties.get().programInformation_credentialProgram()));
 88  0
         configurer.addReadOnlyField(section, ProgramConstants.PROGRAM_CLASSIFICATION, new MessageKeyInfo(ProgramProperties.get().programInformation_classification()));
 89  0
         configurer.addReadOnlyField(section, ProgramConstants.DEGREE_TYPE, new MessageKeyInfo(ProgramProperties.get().programInformation_degreeType()));
 90  0
         return section;
 91  
     }
 92  
 
 93  
     private TableSection createProgramTitleSection() {
 94  0
         TableSection section = new TableSection(SectionTitle.generateH4Title(ProgramProperties.get().programInformation_programTitle()));
 95  0
         configurer.addReadOnlyField(section, ProgramConstants.LONG_TITLE, new MessageKeyInfo(ProgramProperties.get().programInformation_titleFull()));
 96  0
         configurer.addReadOnlyField(section, ProgramConstants.SHORT_TITLE, new MessageKeyInfo(ProgramProperties.get().programInformation_titleShort()));
 97  0
         configurer.addReadOnlyField(section, ProgramConstants.TRANSCRIPT, new MessageKeyInfo(ProgramProperties.get().programInformation_titleTranscript()));
 98  0
         configurer.addReadOnlyField(section, ProgramConstants.DIPLOMA, new MessageKeyInfo(ProgramProperties.get().programInformation_titleDiploma()));
 99  0
         return section;
 100  
     }
 101  
 
 102  
     private TableSection createDatesSection() {
 103  0
         TableSection section = new TableSection(SectionTitle.generateH4Title(ProgramProperties.get().programInformation_dates()));
 104  
         //Add this field and hide it so it is available for cross field validation 
 105  0
         FieldDescriptor fd = configurer.addField(section,ProgramConstants.PREV_START_TERM, new MessageKeyInfo(ProgramProperties.get().majorDiscipline_prevStartTerm()));
 106  0
         fd.getFieldWidget().setVisible(false);
 107  0
         fd.hideLabel();
 108  0
         configurer.addReadOnlyField(section, ProgramConstants.START_TERM, new MessageKeyInfo(ProgramProperties.get().programInformation_startTerm()));
 109  0
         configurer.addReadOnlyField(section, ProgramConstants.END_INSTITUTIONAL_ADMIT_TERM, new MessageKeyInfo(ProgramProperties.get().programInformation_admitTerm()));
 110  0
         configurer.addReadOnlyField(section, ProgramConstants.END_PROGRAM_ENTRY_TERM, new MessageKeyInfo(ProgramProperties.get().programInformation_entryTerm()));
 111  0
         configurer.addReadOnlyField(section, ProgramConstants.END_PROGRAM_ENROLL_TERM, new MessageKeyInfo(ProgramProperties.get().programInformation_enrollTerm()));
 112  0
         configurer.addReadOnlyField(section, ProgramConstants.PROGRAM_APPROVAL_DATE, new MessageKeyInfo(ProgramProperties.get().programInformation_approvalDate()));
 113  0
         return section;
 114  
     }
 115  
 
 116  
     private TableSection createOtherInformationSection() {
 117  0
         TableSection section = new TableSection(SectionTitle.generateH4Title(ProgramProperties.get().programInformation_otherInformation()));
 118  0
         configurer.addReadOnlyField(section, ProgramConstants.LOCATION, new MessageKeyInfo(ProgramProperties.get().programInformation_location()));
 119  0
         FieldDescriptor fd = configurer.addReadOnlyField(section, ProgramConstants.ACCREDITING_AGENCY, new MessageKeyInfo(ProgramProperties.get().programInformation_accreditation()));
 120  0
         fd.setWidgetBinding(new ListToTextBinding(ProgramConstants.ACCREDITING_AGENCY_ORG_ID_TRANSLATION));
 121  0
         configurer.addReadOnlyField(section, ProgramConstants.CIP_2000, new MessageKeyInfo(ProgramProperties.get().programInformation_cip2000()));
 122  0
         configurer.addReadOnlyField(section, ProgramConstants.CIP_2010, new MessageKeyInfo(ProgramProperties.get().programInformation_cip2010()));
 123  0
         configurer.addReadOnlyField(section, ProgramConstants.HEGIS_CODE, new MessageKeyInfo(ProgramProperties.get().programInformation_hegis()));
 124  0
         configurer.addReadOnlyField(section, ProgramConstants.CREDENTIAL_PROGRAM_INSTITUTION_ID, new MessageKeyInfo(ProgramProperties.get().programInformation_institution()));
 125  0
         return section;
 126  
     }
 127  
 
 128  
     public VerticalSection createActivateProgramSection(){
 129  0
         final VerticalSection section = new VerticalSection(SectionTitle.generateH2Title(ProgramProperties.get().programInformation_activateProgram()));
 130  0
         section.setInstructions("<br>" + ProgramProperties.get().programInformation_activateInstructions() + "<br><br>");
 131  0
         controller.requestModel(new ModelRequestCallback<DataModel>(){
 132  
                         public void onModelReady(final DataModel model) {
 133  
                                 //Add previous end dates and update cross constraints
 134  0
                                 WorkflowUtilities.updateCrossField(configurer.addField(section, "proposal/"+ProgramConstants.PREV_END_PROGRAM_ENTRY_TERM, new MessageKeyInfo(ProgramProperties.get().programInformation_entryTerm())), model);
 135  0
                                 WorkflowUtilities.updateCrossField(configurer.addField(section, "proposal/"+ProgramConstants.PREV_END_PROGRAM_ENROLL_TERM, new MessageKeyInfo(ProgramProperties.get().programInformation_enrollTerm())), model);
 136  0
                                 WorkflowUtilities.updateCrossField(configurer.addField(section, "proposal/"+ProgramConstants.PREV_END_INST_ADMIN_TERM, new MessageKeyInfo(ProgramProperties.get().programInformation_entryTerm())), model);
 137  0
                         }
 138  
                         public void onRequestFail(Throwable cause) {
 139  0
                         }
 140  
         });
 141  0
         return section;
 142  
     }
 143  
 
 144  
     // Side-by-side comparison (when controller is not null)  
 145  
     private SummaryTableSection createIdentifyingDetailsSectionEdit() { 
 146  0
               SummaryTableSection section = new SummaryTableSection((Controller) controller);                     
 147  0
               section.setEditable(false);
 148  0
               section.addSummaryTableFieldBlock(createIdentifyingDetailsSectionBlock());
 149  
 
 150  0
         return section;
 151  
     }
 152  
 
 153  
           @SuppressWarnings("unchecked")
 154  
           public SummaryTableFieldBlock createIdentifyingDetailsSectionBlock() {
 155  0
                   SummaryTableFieldBlock block = new SummaryTableFieldBlock();
 156  0
                   block.setTitle(ProgramProperties.get().programInformation_identifyingDetails());
 157  0
                   block.addSummaryTableFieldRow(getFieldRow(ProgramConstants.CODE, new MessageKeyInfo(ProgramProperties.get().programInformation_code())));
 158  0
                   block.addSummaryTableFieldRow(getFieldRow(ProgramConstants.CREDENTIAL_PROGRAM_LEVEL, new MessageKeyInfo(ProgramProperties.get().programInformation_level())));
 159  0
                   block.addSummaryTableFieldRow(getFieldRow(ProgramConstants.CREDENTIAL_PROGRAM_TYPE_NAME, new MessageKeyInfo(ProgramProperties.get().programInformation_credentialProgram())));
 160  0
                   block.addSummaryTableFieldRow(getFieldRow(ProgramConstants.PROGRAM_CLASSIFICATION, new MessageKeyInfo(ProgramProperties.get().programInformation_classification())));
 161  0
                   block.addSummaryTableFieldRow(getFieldRow(ProgramConstants.DEGREE_TYPE, new MessageKeyInfo(ProgramProperties.get().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  
           @SuppressWarnings("unchecked")
 175  
           public SummaryTableFieldBlock createProgramTitleSectionEditBlock() {
 176  0
                   SummaryTableFieldBlock block = new SummaryTableFieldBlock();
 177  0
                   block.setTitle(ProgramProperties.get().programInformation_programTitle());
 178  0
                   block.addSummaryTableFieldRow(getFieldRow(ProgramConstants.LONG_TITLE, new MessageKeyInfo(ProgramProperties.get().programInformation_titleFull())));
 179  0
                   block.addSummaryTableFieldRow(getFieldRow(ProgramConstants.SHORT_TITLE, new MessageKeyInfo(ProgramProperties.get().programInformation_titleShort())));
 180  0
                   block.addSummaryTableFieldRow(getFieldRow(ProgramConstants.TRANSCRIPT, new MessageKeyInfo(ProgramProperties.get().programInformation_titleTranscript())));
 181  0
                   block.addSummaryTableFieldRow(getFieldRow(ProgramConstants.DIPLOMA, new MessageKeyInfo(ProgramProperties.get().programInformation_titleDiploma())));
 182  
 
 183  0
                   return block;
 184  
           }
 185  
           
 186  
     private SummaryTableSection createDatesSectionEdit() { 
 187  0
               SummaryTableSection section = new SummaryTableSection((Controller) controller);                     
 188  0
               section.setEditable(false);
 189  0
               section.addSummaryTableFieldBlock(createDatesSectionEditBlock());
 190  
 
 191  0
         return section;
 192  
     }
 193  
 
 194  
           @SuppressWarnings("unchecked")
 195  
           public SummaryTableFieldBlock createDatesSectionEditBlock() {
 196  0
                   SummaryTableFieldBlock block = new SummaryTableFieldBlock();
 197  0
                   block.setTitle(ProgramProperties.get().programInformation_dates());
 198  0
                   block.addSummaryTableFieldRow(getFieldRow(ProgramConstants.START_TERM, new MessageKeyInfo(ProgramProperties.get().programInformation_startTerm())));
 199  0
                   block.addSummaryTableFieldRow(getFieldRow(ProgramConstants.END_INSTITUTIONAL_ADMIT_TERM, new MessageKeyInfo(ProgramProperties.get().programInformation_admitTerm())));
 200  0
                   block.addSummaryTableFieldRow(getFieldRow(ProgramConstants.END_PROGRAM_ENTRY_TERM, new MessageKeyInfo(ProgramProperties.get().programInformation_entryTerm())));
 201  0
                   block.addSummaryTableFieldRow(getFieldRow(ProgramConstants.END_PROGRAM_ENROLL_TERM, new MessageKeyInfo(ProgramProperties.get().programInformation_enrollTerm())));
 202  0
                   block.addSummaryTableFieldRow(getFieldRow(ProgramConstants.PROGRAM_APPROVAL_DATE, new MessageKeyInfo(ProgramProperties.get().programInformation_approvalDate())));
 203  
  
 204  0
                   return block;
 205  
           }
 206  
 
 207  
     private SummaryTableSection createOtherInformationSectionEdit() { 
 208  0
               SummaryTableSection section = new SummaryTableSection((Controller) controller);                     
 209  0
               section.setEditable(false);
 210  0
               section.addSummaryTableFieldBlock(createOtherInformationSectionEditBlock());
 211  
 
 212  0
         return section;
 213  
     }
 214  
 
 215  
           @SuppressWarnings("unchecked")
 216  
           public SummaryTableFieldBlock createOtherInformationSectionEditBlock() {
 217  0
                   SummaryTableFieldBlock block = new SummaryTableFieldBlock();
 218  0
                   block.setTitle(ProgramProperties.get().programInformation_otherInformation());
 219  0
                   block.addSummaryTableFieldRow(getFieldRow(ProgramConstants.LOCATION, new MessageKeyInfo(ProgramProperties.get().programInformation_location())));
 220  0
         block.addSummaryTableFieldRow(getFieldRow(ProgramConstants.ACCREDITING_AGENCY,
 221  
                         new MessageKeyInfo(ProgramProperties.get().programInformation_accreditation()), null,
 222  
                 null, null, new ListToTextBinding(ProgramConstants.ACCREDITING_AGENCY_ORG_ID_TRANSLATION), false));        
 223  0
         block.addSummaryTableFieldRow(getFieldRow(ProgramConstants.CIP_2000, new MessageKeyInfo(ProgramProperties.get().programInformation_cip2000())));
 224  0
                   block.addSummaryTableFieldRow(getFieldRow(ProgramConstants.CIP_2010, new MessageKeyInfo(ProgramProperties.get().programInformation_cip2010())));
 225  0
                   block.addSummaryTableFieldRow(getFieldRow(ProgramConstants.HEGIS_CODE, new MessageKeyInfo(ProgramProperties.get().programInformation_hegis())));
 226  0
                   block.addSummaryTableFieldRow(getFieldRow(ProgramConstants.CREDENTIAL_PROGRAM_INSTITUTION_ID, new MessageKeyInfo(ProgramProperties.get().programInformation_institution())));
 227  
                    
 228  0
                   return block;
 229  
           }
 230  
           
 231  
           protected SummaryTableFieldRow getFieldRow(String fieldKey, MessageKeyInfo messageKey) {
 232  0
                   return getFieldRow(fieldKey, messageKey, null, null, null, null, false);
 233  
           }
 234  
      
 235  
           protected SummaryTableFieldRow getFieldRow(String fieldKey,
 236  
                           MessageKeyInfo messageKey, Widget widget, Widget widget2,
 237  
                           String parentPath, ModelWidgetBinding<?> binding, boolean optional) 
 238  
           {
 239  0
                   QueryPath path = QueryPath.concat(parentPath, fieldKey);
 240  0
                   Metadata meta = configurer.getModelDefinition().getMetadata(path);
 241  
 
 242  0
                   FieldDescriptorReadOnly fd = new FieldDescriptorReadOnly(path.toString(), messageKey, meta);
 243  0
                   if (widget != null) {
 244  0
                           fd.setFieldWidget(widget);
 245  
                   }
 246  0
                   if (binding != null) {
 247  0
                           fd.setWidgetBinding(binding);
 248  
                   }
 249  0
                   fd.setOptional(optional);
 250  
 
 251  0
                   FieldDescriptorReadOnly fd2 = new FieldDescriptorReadOnly(path.toString(), messageKey, meta);
 252  0
                   if (widget2 != null) {
 253  0
                           fd2.setFieldWidget(widget2);
 254  
                   }
 255  0
                   if (binding != null) {
 256  0
                           fd2.setWidgetBinding(binding);
 257  
                   }
 258  0
                   fd2.setOptional(optional);
 259  
 
 260  0
                   SummaryTableFieldRow fieldRow = new SummaryTableFieldRow(fd, fd2);
 261  
 
 262  0
                   return fieldRow;
 263  
           }    
 264  
 }