Coverage Report - org.kuali.rice.krad.datadictionary.InquiryDefinition
 
Classes in this File Line Coverage Branch Coverage Complexity
InquiryDefinition
0%
0/37
0%
0/14
1.588
 
 1  
 /*
 2  
  * Copyright 2005-2007 The Kuali Foundation
 3  
  * 
 4  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  * 
 8  
  * http://www.opensource.org/licenses/ecl2.php
 9  
  * 
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 
 17  
 package org.kuali.rice.krad.datadictionary;
 18  
 
 19  
 import java.util.ArrayList;
 20  
 import java.util.List;
 21  
 
 22  
 import org.apache.commons.lang.StringUtils;
 23  
 import org.kuali.rice.krad.inquiry.Inquirable;
 24  
 import org.kuali.rice.krad.inquiry.InquiryAuthorizer;
 25  
 import org.kuali.rice.krad.inquiry.InquiryPresentationController;
 26  
 
 27  
 /**
 28  
     The inquiry element is used to specify the fields that will be displayed on the
 29  
     inquiry screen for this business object and the order in which they will appear.
 30  
 
 31  
     JSTL: The inquiry element is a Map which is accessed using
 32  
     a key of "inquiry".  This map contains the following keys:
 33  
         * title (String)
 34  
         * inquiryFields (Map)
 35  
  */
 36  
 public class InquiryDefinition extends DataDictionaryDefinitionBase {
 37  
     private static final long serialVersionUID = -2506403061297774668L;
 38  
     
 39  
         protected String title;
 40  0
     protected List<InquirySectionDefinition> inquirySections = new ArrayList<InquirySectionDefinition>();
 41  
     protected Class<? extends Inquirable> inquirableClass;
 42  
     protected Class<? extends InquiryPresentationController> presentationControllerClass;
 43  
     protected Class<? extends InquiryAuthorizer> authorizerClass;
 44  
     
 45  0
     protected boolean translateCodes = true;
 46  
 
 47  0
     public InquiryDefinition() {
 48  0
     }
 49  
 
 50  
 
 51  
     public String getTitle() {
 52  0
         return title;
 53  
     }
 54  
 
 55  
     /**
 56  
                The title element is used specify the title that will appear in the header
 57  
                 of an Inquiry or Lookup screen.
 58  
      * @throws IllegalArgumentException if the given title is blank
 59  
      */
 60  
     public void setTitle(String title) {
 61  0
         if (StringUtils.isBlank(title)) {
 62  0
             throw new IllegalArgumentException("invalid (blank) title");
 63  
         }
 64  
 
 65  0
         this.title = title;
 66  0
     }
 67  
 
 68  
     /**
 69  
      * @return Collection of all inquiryField FieldDefinitions associated with this InquiryDefinition, in the order in which they
 70  
      *         were added
 71  
      */
 72  
     public List<InquirySectionDefinition> getInquirySections() {
 73  0
         return inquirySections;
 74  
     }
 75  
    
 76  
     /**
 77  
      * Returns the FieldDefinition associated with the field attribute name
 78  
      * @param fieldName
 79  
      * @return
 80  
      */
 81  
     public FieldDefinition getFieldDefinition(String fieldName) {
 82  0
         for (InquirySectionDefinition section : inquirySections ) {
 83  0
             for (FieldDefinition field : section.getInquiryFields() ) {
 84  0
                 if (field.getAttributeName().equals(fieldName)) {
 85  0
                     return field;
 86  
                 }
 87  
             }
 88  
         }
 89  
         
 90  0
         return null;
 91  
     }
 92  
 
 93  
     /**
 94  
      * Directly validate simple fields, call completeValidation on Definition fields.
 95  
      * 
 96  
      * @see org.kuali.rice.krad.datadictionary.DataDictionaryDefinition#completeValidation(java.lang.Class, java.lang.Object)
 97  
      */
 98  
     public void completeValidation(Class rootBusinessObjectClass, Class otherBusinessObjectClass) {
 99  0
         for ( InquirySectionDefinition inquirySection : inquirySections ) {
 100  0
             inquirySection.completeValidation(rootBusinessObjectClass, null);
 101  
         }
 102  0
     }
 103  
 
 104  
     public InquirySectionDefinition getInquirySection( String sectionTitle ) {
 105  0
         for ( InquirySectionDefinition inquirySection : inquirySections ) {
 106  0
             if ( inquirySection.getTitle().equals(sectionTitle) ) {
 107  0
                 return inquirySection;
 108  
             }
 109  
         }
 110  0
         return null;
 111  
     }
 112  
     
 113  
     
 114  
     /**
 115  
      * @see java.lang.Object#toString()
 116  
      */
 117  
     public String toString() {
 118  0
         return "InquiryDefinition '" + getTitle() + "'";
 119  
     }
 120  
 
 121  
 
 122  
     public Class<? extends Inquirable> getInquirableClass() {
 123  0
         return inquirableClass;
 124  
     }
 125  
 
 126  
     /**
 127  
 
 128  
             inquirableClass is required if a custom inquirable is required which will show
 129  
             additional data other than the business object attributes.
 130  
 
 131  
             Example from Org.xml:
 132  
                 <inquirableClass>org.kuali.module.chart.maintenance.OrgInquirable</inquirableClass>
 133  
             The custom inquirable is required in this case because the organization hierarchy
 134  
             is shown on the inquiry screen.
 135  
      */
 136  
     public void setInquirableClass(Class<? extends Inquirable> inquirableClass) {
 137  0
         this.inquirableClass = inquirableClass;
 138  0
     }
 139  
 
 140  
     /**
 141  
      *                 inquirySections allows inquiry to be presented in sections.
 142  
                 Each section can have a different format.
 143  
      */
 144  
     public void setInquirySections(List<InquirySectionDefinition> inquirySections) {
 145  0
         this.inquirySections = inquirySections;
 146  0
     }
 147  
 
 148  
 
 149  
         public Class<? extends InquiryPresentationController> getPresentationControllerClass() {
 150  0
                 return this.presentationControllerClass;
 151  
         }
 152  
 
 153  
 
 154  
         public void setPresentationControllerClass(
 155  
                         Class<? extends InquiryPresentationController> presentationControllerClass) {
 156  0
                 this.presentationControllerClass = presentationControllerClass;
 157  0
         }
 158  
 
 159  
 
 160  
         public Class<? extends InquiryAuthorizer> getAuthorizerClass() {
 161  0
                 return this.authorizerClass;
 162  
         }
 163  
 
 164  
 
 165  
         public void setAuthorizerClass(
 166  
                         Class<? extends InquiryAuthorizer> authorizerClass) {
 167  0
                 this.authorizerClass = authorizerClass;
 168  0
         }
 169  
 
 170  
 
 171  
         public boolean isTranslateCodes() {
 172  0
                 return this.translateCodes;
 173  
         }
 174  
 
 175  
 
 176  
         public void setTranslateCodes(boolean translateCodes) {
 177  0
                 this.translateCodes = translateCodes;
 178  0
         }
 179  
         
 180  
 }