001/** 002 * Copyright 2005-2014 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.krad.uif.service; 017 018import org.kuali.rice.krad.data.metadata.DataObjectAttribute; 019import org.kuali.rice.krad.data.metadata.DataObjectMetadata; 020import org.kuali.rice.krad.datadictionary.AttributeDefinition; 021import org.kuali.rice.krad.datadictionary.DataObjectEntry; 022import org.kuali.rice.krad.datadictionary.validation.constraint.ValidCharactersConstraint; 023import org.kuali.rice.krad.lookup.LookupView; 024import org.kuali.rice.krad.uif.control.Control; 025import org.kuali.rice.krad.uif.view.InquiryView; 026 027/** 028 * This service helps build/define default controls for the UIF based on the associated data-level metadata. 029 * 030 * It will use the information provided by the krad-data module to attempt to build sensible 031 * default controls based on the data type, maximum length, and other attributes available 032 * in the ORM-level metadata or provided as annotations on the data object classes. 033 * 034 * @author Kuali Rice Team (rice.collab@kuali.org) 035 */ 036public interface UifDefaultingService { 037 038 /** 039 * Derives a UIF control from the information available on the passed in Data Dictionary {@link AttributeDefinition}. 040 * 041 * Attempts to build reasonable defaults based on the data type and other metadata which has 042 * been included. 043 * 044 * If no special information is found in the metadata, it will return a standard/default text control. 045 * @param attrDef attribute definition 046 * @return derived control 047 */ 048 Control deriveControlAttributeFromMetadata( AttributeDefinition attrDef ); 049 050 /** 051 * Helper method to allow reasonable names to be defaulted from class or property names. 052 * 053 * This method assumes that the passed in name is camel-cased and will create the 054 * name by adding spaces before each capital letter or digit as well as capitalizing each word. 055 * 056 * In the case that the name given is a nested property, only the portion of the 057 * name after the last period will be used. 058 * @param camelCasedName property name, in camel case 059 * @return human friendly property name 060 */ 061 String deriveHumanFriendlyNameFromPropertyName(String camelCasedName); 062 063 /** 064 * Derives a default valid characters constraint definition given the metadata in the {@link AttributeDefinition} 065 * @param attrDef attribute definition 066 * 067 * @return A {@link ValidCharactersConstraint} object or null if no information in the {@link AttributeDefinition} suggests an appropriate default. 068 */ 069 ValidCharactersConstraint deriveValidCharactersConstraint( AttributeDefinition attrDef ); 070 071 /** 072 * Build an instance of an {@link InquiryView} for the given data object entry. 073 * Information will be pulled from the {@link DataObjectEntry} and the embedded 074 * {@link DataObjectMetadata} and {@link DataObjectAttribute} instances as needed. 075 * 076 * In the present implementation, all non-hidden properties on the DataObjectEntry 077 * will be added to the inquiry. Additionally, any collections on the object will be 078 * displayed in their own sections. 079 * @param dataObjectEntry data object entry 080 * @return inquiry view based on the data object 081 */ 082 InquiryView deriveInquiryViewFromMetadata( DataObjectEntry dataObjectEntry ); 083 084 /** 085 * Build an instance of an {@link LookupView} for the given data object entry. 086 * Information will be pulled from the {@link DataObjectEntry} and the embedded 087 * {@link DataObjectMetadata} and {@link DataObjectAttribute} instances as needed. 088 * 089 * In the present implementation, all non-hidden properties on the DataObjectEntry 090 * will be added to the lookup search criteria and results. 091 * @param dataObjectEntry data object entry 092 * @return lookup view based on the data object 093 */ 094 LookupView deriveLookupViewFromMetadata( DataObjectEntry dataObjectEntry ); 095}