View Javadoc
1   /**
2    * Copyright 2005-2015 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.datadictionary;
17  
18  import org.apache.commons.lang.StringUtils;
19  import org.kuali.rice.kns.inquiry.InquiryAuthorizer;
20  import org.kuali.rice.kns.inquiry.InquiryPresentationController;
21  import org.kuali.rice.krad.datadictionary.DataDictionaryDefinitionBase;
22  import org.kuali.rice.krad.inquiry.Inquirable;
23  
24  import java.util.ArrayList;
25  import java.util.List;
26  
27  /**
28   * The inquiry element is used to specify the fields that will be displayed on the inquiry screen for this business
29   * object and the order in which they will appear.
30   *
31   * JSTL: The inquiry element is a Map which is accessed using a key of "inquiry".  This map contains the following keys:
32   *      * title (String)
33   *      * inquiryFields (Map)
34   *
35   * @deprecated Use {@link org.kuali.rice.krad.uif.view.InquiryView}.
36   */
37  @Deprecated
38  public class InquiryDefinition extends DataDictionaryDefinitionBase {
39      private static final long serialVersionUID = -2506403061297774668L;
40      
41  	protected String title;
42      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      protected boolean translateCodes = true;
48  
49      public InquiryDefinition() {
50      }
51  
52  
53      public String getTitle() {
54          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          if (StringUtils.isBlank(title)) {
64              throw new IllegalArgumentException("invalid (blank) title");
65          }
66  
67          this.title = title;
68      }
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          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          for (InquirySectionDefinition section : inquirySections ) {
85              for (FieldDefinition field : section.getInquiryFields() ) {
86                  if (field.getAttributeName().equals(fieldName)) {
87                      return field;
88                  }
89              }
90          }
91          
92          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         for ( InquirySectionDefinition inquirySection : inquirySections ) {
102             inquirySection.completeValidation(rootBusinessObjectClass, null);
103         }
104     }
105 
106     public InquirySectionDefinition getInquirySection( String sectionTitle ) {
107         for ( InquirySectionDefinition inquirySection : inquirySections ) {
108             if ( inquirySection.getTitle().equals(sectionTitle) ) {
109                 return inquirySection;
110             }
111         }
112         return null;
113     }
114     
115     
116     /**
117      * @see java.lang.Object#toString()
118      */
119     public String toString() {
120         return "InquiryDefinition '" + getTitle() + "'";
121     }
122 
123 
124     public Class<? extends Inquirable> getInquirableClass() {
125         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         this.inquirableClass = inquirableClass;
140     }
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         this.inquirySections = inquirySections;
148     }
149 
150 
151 	public Class<? extends InquiryPresentationController> getPresentationControllerClass() {
152 		return this.presentationControllerClass;
153 	}
154 
155 
156 	public void setPresentationControllerClass(
157 			Class<? extends InquiryPresentationController> presentationControllerClass) {
158 		this.presentationControllerClass = presentationControllerClass;
159 	}
160 
161 
162 	public Class<? extends InquiryAuthorizer> getAuthorizerClass() {
163 		return this.authorizerClass;
164 	}
165 
166 
167 	public void setAuthorizerClass(
168 			Class<? extends InquiryAuthorizer> authorizerClass) {
169 		this.authorizerClass = authorizerClass;
170 	}
171 
172 
173 	public boolean isTranslateCodes() {
174 		return this.translateCodes;
175 	}
176 
177 
178 	public void setTranslateCodes(boolean translateCodes) {
179 		this.translateCodes = translateCodes;
180 	}
181 	
182 }