Coverage Report - org.kuali.student.common.ui.client.configurable.mvc.multiplicity.MultiplicityFieldConfiguration
 
Classes in this File Line Coverage Branch Coverage Complexity
MultiplicityFieldConfiguration
0%
0/39
0%
0/8
1.25
 
 1  
 package org.kuali.student.common.ui.client.configurable.mvc.multiplicity;
 2  
 
 3  
 import org.kuali.student.common.assembly.data.Metadata;
 4  
 import org.kuali.student.common.assembly.data.MetadataInterrogator;
 5  
 import org.kuali.student.common.ui.client.configurable.mvc.binding.ModelWidgetBinding;
 6  
 import org.kuali.student.common.ui.client.widgets.field.layout.element.MessageKeyInfo;
 7  
 
 8  
 public class MultiplicityFieldConfiguration {
 9  
     
 10  
     private String fieldPath;
 11  
     private MessageKeyInfo messageKeyInfo;
 12  
     private Metadata metadata;
 13  
     private MultiplicityFieldWidgetInitializer fieldWidgetInitializer;
 14  
     @SuppressWarnings("unchecked")
 15  
         private ModelWidgetBinding modelWidgetBinding;
 16  
     private boolean isRequired;
 17  0
         private boolean optional = false;
 18  
     
 19  
     public MultiplicityFieldConfiguration(
 20  
             String fieldPath,
 21  
             MessageKeyInfo messageKeyInfo,
 22  
             Metadata metadata,
 23  0
             MultiplicityFieldWidgetInitializer fieldWidgetInitializer) {
 24  0
         setFieldPath(fieldPath);
 25  0
         setMessageKeyInfo(messageKeyInfo);
 26  0
         setMetadata(metadata);
 27  0
         setFieldWidgetInitializer(fieldWidgetInitializer);
 28  0
         setupField();
 29  0
     }
 30  
     
 31  
     public String getFieldPath() {
 32  0
         return fieldPath;
 33  
     }
 34  
     public void setFieldPath(String fieldPath) {
 35  0
         this.fieldPath = fieldPath;
 36  0
     }
 37  
     public MessageKeyInfo getMessageKeyInfo() {
 38  0
         return messageKeyInfo;
 39  
     }
 40  
     public void setMessageKeyInfo(MessageKeyInfo messageKeyInfo) {
 41  0
         this.messageKeyInfo = messageKeyInfo;
 42  0
     }
 43  
     public Metadata getMetadata() {
 44  0
         return metadata;
 45  
     }
 46  
     public void setMetadata(Metadata metadata) {
 47  0
         this.metadata = metadata;
 48  0
     }
 49  
     public MultiplicityFieldWidgetInitializer getFieldWidgetInitializer() {
 50  0
         return fieldWidgetInitializer;
 51  
     }
 52  
     public void setFieldWidgetInitializer(MultiplicityFieldWidgetInitializer fieldWidgetInitializer) {
 53  0
         this.fieldWidgetInitializer = fieldWidgetInitializer;
 54  0
     }
 55  
 
 56  
     public boolean isRequired() {
 57  0
         return isRequired;
 58  
     }
 59  
 
 60  
     public void setRequired(boolean isRequired) {
 61  0
         this.isRequired = isRequired;
 62  0
     }
 63  
 
 64  
         public void setModelWidgetBinding(ModelWidgetBinding modelWidgetBinding) {
 65  0
                 this.modelWidgetBinding = modelWidgetBinding;
 66  0
         }
 67  
 
 68  
         public ModelWidgetBinding getModelWidgetBinding() {
 69  0
                 return modelWidgetBinding;
 70  
         }
 71  
         
 72  
         
 73  
         /**
 74  
          * Sets the optional flag
 75  
          * Fields that are optional should not be displayed if there is no data in some cases,
 76  
          * it is up to the section implementation whether or not to honor this flag
 77  
          * @param optional
 78  
          */
 79  
         public void setOptional(boolean optional){
 80  0
                 this.optional = optional;
 81  0
         }
 82  
         
 83  
         /**
 84  
          * Fields that are optional should not be displayed if there is no data in some cases,
 85  
          * it is up to the section implementation whether or not to honor this flag
 86  
          */
 87  
         public boolean isOptional(){
 88  0
                 return optional;
 89  
         }
 90  
         
 91  
         protected void setupField() {
 92  0
         if(metadata != null){
 93  0
             if(MetadataInterrogator.isRequired(metadata)){
 94  0
                 this.setRequired(true);
 95  
             }
 96  0
             else if(MetadataInterrogator.isRequiredForNextState(metadata)){
 97  0
                 String nextState = MetadataInterrogator.getNextState(metadata);
 98  0
                 if(nextState != null){
 99  0
                     this.setRequired(true);
 100  
                 }
 101  0
             } else{
 102  0
                 this.setRequired(false);
 103  
             }
 104  
         }
 105  0
     }
 106  
 }