1 /**
2 * Copyright 2005-2014 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.data.jpa;
17
18 import org.kuali.rice.core.api.criteria.Predicate;
19 import org.kuali.rice.core.api.criteria.QueryByCriteria;
20
21 import javax.persistence.Query;
22
23 /**
24 * Translates queries from generic API classes to platform-specific concrete classes.
25 *
26 * @author Kuali Rice Team (rice.collab@kuali.org)
27 */
28 interface QueryTranslator<C, Q> {
29
30 /**
31 * Translates the given {@link org.kuali.rice.core.api.criteria.QueryByCriteria} to a platform-specific criteria.
32 *
33 * @param queryClazz the type of the query.
34 * @param criteria the {@link org.kuali.rice.core.api.criteria.QueryByCriteria} to translate.
35 * @return a criteria for the given {@link org.kuali.rice.core.api.criteria.QueryByCriteria}.
36 */
37 C translateCriteria(Class queryClazz, QueryByCriteria criteria);
38
39 /**
40 * Creates a query from the given criteria.
41 *
42 * @param queryClazz the type of the query.
43 * @param criteria the criteria to translate.
44 * @return a query from the given criteria.
45 */
46 Q createQuery(Class queryClazz, C criteria);
47
48 /**
49 * Creates a query to delete records from the given criteria
50 * @param queryClass the type of the query
51 * @param criteria the criteria to translate
52 * @return a query from the given criteria
53 */
54 Query createDeletionQuery(Class queryClass, C criteria);
55
56 /**
57 * Translates the {@link QueryByCriteria} flags to the query.
58 * @param qbc the {@link QueryByCriteria} to translate from.
59 * @param query the query to translate to.
60 */
61 void convertQueryFlags(QueryByCriteria qbc, Q query);
62 }