001/** 002 * Copyright 2005-2016 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.kuali.rice.kns.datadictionary; 017 018import org.apache.commons.lang.StringUtils; 019import org.kuali.rice.kns.inquiry.InquiryAuthorizer; 020import org.kuali.rice.kns.inquiry.InquiryPresentationController; 021import org.kuali.rice.krad.datadictionary.DataDictionaryDefinitionBase; 022import org.kuali.rice.krad.inquiry.Inquirable; 023 024import java.util.ArrayList; 025import java.util.List; 026 027/** 028 * The inquiry element is used to specify the fields that will be displayed on the inquiry screen for this business 029 * object and the order in which they will appear. 030 * 031 * JSTL: The inquiry element is a Map which is accessed using a key of "inquiry". This map contains the following keys: 032 * * title (String) 033 * * inquiryFields (Map) 034 * 035 * @deprecated Use {@link org.kuali.rice.krad.uif.view.InquiryView}. 036 */ 037@Deprecated 038public class InquiryDefinition extends DataDictionaryDefinitionBase { 039 private static final long serialVersionUID = -2506403061297774668L; 040 041 protected String title; 042 protected List<InquirySectionDefinition> inquirySections = new ArrayList<InquirySectionDefinition>(); 043 protected Class<? extends Inquirable> inquirableClass; 044 protected Class<? extends InquiryPresentationController> presentationControllerClass; 045 protected Class<? extends InquiryAuthorizer> authorizerClass; 046 047 protected boolean translateCodes = true; 048 049 public InquiryDefinition() { 050 } 051 052 053 public String getTitle() { 054 return title; 055 } 056 057 /** 058 The title element is used specify the title that will appear in the header 059 of an Inquiry or Lookup screen. 060 * @throws IllegalArgumentException if the given title is blank 061 */ 062 public void setTitle(String title) { 063 if (StringUtils.isBlank(title)) { 064 throw new IllegalArgumentException("invalid (blank) title"); 065 } 066 067 this.title = title; 068 } 069 070 /** 071 * @return Collection of all inquiryField FieldDefinitions associated with this InquiryDefinition, in the order in which they 072 * were added 073 */ 074 public List<InquirySectionDefinition> getInquirySections() { 075 return inquirySections; 076 } 077 078 /** 079 * Returns the FieldDefinition associated with the field attribute name 080 * @param fieldName 081 * @return 082 */ 083 public FieldDefinition getFieldDefinition(String fieldName) { 084 for (InquirySectionDefinition section : inquirySections ) { 085 for (FieldDefinition field : section.getInquiryFields() ) { 086 if (field.getAttributeName().equals(fieldName)) { 087 return field; 088 } 089 } 090 } 091 092 return null; 093 } 094 095 /** 096 * Directly validate simple fields, call completeValidation on Definition fields. 097 * 098 * @see org.kuali.rice.krad.datadictionary.DataDictionaryDefinition#completeValidation(java.lang.Class, java.lang.Object) 099 */ 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}