View Javadoc

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