001    package org.apache.ojb.broker.accesslayer;
002    
003    /* Copyright 2003-2005 The Apache Software Foundation
004     *
005     * Licensed under the Apache License, Version 2.0 (the "License");
006     * you may not use this file except in compliance with the License.
007     * You may obtain a copy of the License at
008     *
009     *     http://www.apache.org/licenses/LICENSE-2.0
010     *
011     * Unless required by applicable law or agreed to in writing, software
012     * distributed under the License is distributed on an "AS IS" BASIS,
013     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014     * See the License for the specific language governing permissions and
015     * limitations under the License.
016     */
017    
018    import org.apache.ojb.broker.PersistenceBroker;
019    import org.apache.ojb.broker.metadata.AttributeContainer;
020    import org.apache.ojb.broker.metadata.CollectionDescriptor;
021    import org.apache.ojb.broker.query.Query;
022    import org.apache.ojb.broker.query.QueryByCriteria;
023    
024    /**
025     * Interface for QueryCustomizer in CollectionDescriptor
026     * <pre>
027     * ...
028     *   <query-customizer
029     *     class="org.apache.ojb.broker.accesslayer.QueryCustomizerDefaultImpl">
030     *   <attribute
031     *     attribute-name="attr1"
032     *     attribute-value="value1"
033     *   />
034     * ...
035     * </pre>
036     *
037     * If the customized Query is null execution of PB retrieveCollection is skipped
038     * and an empty Collection is placed in the relationship attribute.
039     * 
040     * @see org.apache.ojb.broker.PersistenceBroker#getCollectionByQuery
041     *
042     * @author <a href="mailto:jbraeuchi@hotmail.com">Jakob Braeuchi</a>
043     * @version $Id: QueryCustomizer.java,v 1.1 2007-08-24 22:17:30 ewestfal Exp $
044     */
045    public interface QueryCustomizer extends AttributeContainer
046    {
047        /**
048         * Return a new Query based on the original Query, the originator object and
049         * the additional Attributes.
050         *
051         * @param anObject the originator object
052         * @param aBroker the PersistenceBroker
053         * @param aCod the CollectionDescriptor
054         * @param aQuery the original 1:n-Query
055         * @return Query the customized 1:n-Query, return null to skip execution of the query
056         */
057        public Query customizeQuery(Object anObject, PersistenceBroker aBroker, CollectionDescriptor aCod, QueryByCriteria aQuery);
058    }