View Javadoc

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