1 /** 2 * Copyright 2005-2016 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.krad.uif.service; 17 18 import org.kuali.rice.krad.data.metadata.DataObjectAttribute; 19 import org.kuali.rice.krad.data.metadata.DataObjectMetadata; 20 import org.kuali.rice.krad.datadictionary.AttributeDefinition; 21 import org.kuali.rice.krad.datadictionary.DataObjectEntry; 22 import org.kuali.rice.krad.datadictionary.validation.constraint.ValidCharactersConstraint; 23 import org.kuali.rice.krad.lookup.LookupView; 24 import org.kuali.rice.krad.uif.control.Control; 25 import org.kuali.rice.krad.uif.view.InquiryView; 26 27 /** 28 * This service helps build/define default controls for the UIF based on the associated data-level metadata. 29 * 30 * It will use the information provided by the krad-data module to attempt to build sensible 31 * default controls based on the data type, maximum length, and other attributes available 32 * in the ORM-level metadata or provided as annotations on the data object classes. 33 * 34 * @author Kuali Rice Team (rice.collab@kuali.org) 35 */ 36 public interface UifDefaultingService { 37 38 /** 39 * Derives a UIF control from the information available on the passed in Data Dictionary {@link AttributeDefinition}. 40 * 41 * Attempts to build reasonable defaults based on the data type and other metadata which has 42 * been included. 43 * 44 * If no special information is found in the metadata, it will return a standard/default text control. 45 * @param attrDef attribute definition 46 * @return derived control 47 */ 48 Control deriveControlAttributeFromMetadata( AttributeDefinition attrDef ); 49 50 /** 51 * Helper method to allow reasonable names to be defaulted from class or property names. 52 * 53 * This method assumes that the passed in name is camel-cased and will create the 54 * name by adding spaces before each capital letter or digit as well as capitalizing each word. 55 * 56 * In the case that the name given is a nested property, only the portion of the 57 * name after the last period will be used. 58 * @param camelCasedName property name, in camel case 59 * @return human friendly property name 60 */ 61 String deriveHumanFriendlyNameFromPropertyName(String camelCasedName); 62 63 /** 64 * Derives a default valid characters constraint definition given the metadata in the {@link AttributeDefinition} 65 * @param attrDef attribute definition 66 * 67 * @return A {@link ValidCharactersConstraint} object or null if no information in the {@link AttributeDefinition} suggests an appropriate default. 68 */ 69 ValidCharactersConstraint deriveValidCharactersConstraint( AttributeDefinition attrDef ); 70 71 /** 72 * Build an instance of an {@link InquiryView} for the given data object entry. 73 * Information will be pulled from the {@link DataObjectEntry} and the embedded 74 * {@link DataObjectMetadata} and {@link DataObjectAttribute} instances as needed. 75 * 76 * In the present implementation, all non-hidden properties on the DataObjectEntry 77 * will be added to the inquiry. Additionally, any collections on the object will be 78 * displayed in their own sections. 79 * @param dataObjectEntry data object entry 80 * @return inquiry view based on the data object 81 */ 82 InquiryView deriveInquiryViewFromMetadata( DataObjectEntry dataObjectEntry ); 83 84 /** 85 * Build an instance of an {@link LookupView} for the given data object entry. 86 * Information will be pulled from the {@link DataObjectEntry} and the embedded 87 * {@link DataObjectMetadata} and {@link DataObjectAttribute} instances as needed. 88 * 89 * In the present implementation, all non-hidden properties on the DataObjectEntry 90 * will be added to the lookup search criteria and results. 91 * @param dataObjectEntry data object entry 92 * @return lookup view based on the data object 93 */ 94 LookupView deriveLookupViewFromMetadata( DataObjectEntry dataObjectEntry ); 95 }