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.krad.data.jpa; 017 018import java.lang.annotation.Retention; 019import java.lang.annotation.Target; 020 021import static java.lang.annotation.ElementType.FIELD; 022import static java.lang.annotation.ElementType.METHOD; 023import static java.lang.annotation.ElementType.TYPE; 024import static java.lang.annotation.RetentionPolicy.RUNTIME; 025 026/** 027 * Defines a filter generator that will alter the query for an annotated field. 028 * 029 * <pre> 030 * Examples: 031 * 032 * @FilterGenerator(attributeName = "accountTypeCode",attributeResolverClass = 033 * "org.kuali.rice.krad.data.bo.TestQueryCustomizerValue") 034 * private TestRelatedExtension accountExtension; 035 * </pre> 036 * 037 * <p> 038 * Currently, in order for this annotation to work properly, the 039 * {@link org.kuali.rice.krad.data.jpa.eclipselink.KradEclipseLinkCustomizer} must be configured for the EclipseLink 040 * persistence unit. This can be done manually using 041 * {@link org.eclipse.persistence.config.PersistenceUnitProperties#SESSION_CUSTOMIZER}, or it will be done automatically 042 * when using {@link org.kuali.rice.krad.data.jpa.eclipselink.KradEclipseLinkEntityManagerFactoryBean}. 043 * </p> 044 * 045 * @author Kuali Rice Team (rice.collab@kuali.org) 046 **/ 047@Target({TYPE, METHOD, FIELD}) 048@Retention(RUNTIME) 049public @interface FilterGenerator { 050 051 /** 052 * (Required) The attribute name to have the customization applied in the query. 053 * 054 * @return the attribute name to have the customization applied in the query. 055 */ 056 String attributeName(); 057 058 /** 059 * (Optional) The operator that will be used for this fragment expression. 060 * 061 * <p>Defaults to EQUAL.</p> 062 * 063 * @return the operator that will be used for this fragment expression. 064 */ 065 FilterOperators operator() default FilterOperators.EQUAL; 066 067 /** 068 * (Optional) The value that the attribute named will be used to build expression fragment. 069 * 070 * <p>Defaults to an empty string.</p> 071 * 072 * @return the value that the attribute named will be used to build expression fragment. 073 */ 074 String attributeValue() default ""; 075 076 /** 077 * (Optional) The class that resolves the value that the attribute named will be used to build expression fragment. 078 * 079 * <p>Defaults to the Void class.</p> 080 * 081 * @return the class that resolves the value that the attribute named will be used to build expression fragment. 082 */ 083 Class<?> attributeResolverClass() default Void.class; 084}