001/* 002 * (C) Copyright 2006-2011 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache 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.apache.org/licenses/LICENSE-2.0 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 * 016 * Contributors: 017 * Florent Guillaume 018 */ 019 020package org.nuxeo.ecm.core.storage.sql; 021 022import org.nuxeo.ecm.core.query.QueryFilter; 023import org.nuxeo.ecm.core.storage.sql.Session.PathResolver; 024import org.nuxeo.ecm.core.storage.sql.jdbc.QueryMaker; 025import org.nuxeo.ecm.core.storage.sql.jdbc.SQLInfo; 026 027/** 028 * A dummy QueryMaker usable to capture the low level sqlInfo, model and session from a high-level session, in order to 029 * further test QueryMakers. 030 * 031 * @author Florent Guillaume 032 */ 033public class CapturingQueryMaker implements QueryMaker { 034 035 public static final String TYPE = "test-capturing"; 036 037 public static class Captured { 038 public SQLInfo sqlInfo; 039 040 public Model model; 041 042 public PathResolver pathResolver; 043 } 044 045 @Override 046 public String getName() { 047 return TYPE; 048 } 049 050 @Override 051 public boolean accepts(String queryType) { 052 return TYPE.equals(queryType); 053 } 054 055 @Override 056 public Query buildQuery(SQLInfo sqlInfo, Model model, PathResolver pathResolver, String query, 057 QueryFilter queryFilter, Object... params) { 058 Captured captured = (Captured) params[0]; 059 captured.sqlInfo = sqlInfo; 060 captured.model = model; 061 captured.pathResolver = pathResolver; 062 return null; 063 } 064}