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