Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* $Id$
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.tiles.test.db;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import org.apache.tiles.Attribute;
import org.apache.tiles.Definition;
import org.apache.tiles.definition.dao.DefinitionDAO;
import org.apache.tiles.request.locale.LocaleUtil;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.core.support.JdbcDaoSupport;
/**
* Stub definition DAO to demonstrate that Tiles definitions can be stored in a
* Database.
*
* @version $Rev$ $Date$
*/
public class LocaleDbDefinitionDAO extends JdbcDaoSupport implements
DefinitionDAO {
/**
* Selects a customization by its name.
*/
private static final String SELECT_CUSTOMIZATION_BY_NAME_SQL =
"select ID, PARENT_ID, NAME from CUSTOMIZATION "
+ "where NAME = ? ";
/**
* Selects a customization by its Id.
*/
private static final String SELECT_CUSTOMIZATION_BY_ID_SQL =
"select ID, PARENT_ID, NAME from CUSTOMIZATION "
+ "where ID = ? ";
/**
* Selects a definition by its name and a customization Id.
*/
private static final String SELECT_DEFINITION_SQL =
"select ID, PARENT_NAME, NAME, PREPARER, TEMPLATE from DEFINITION "
+ "where NAME = ? and CUSTOMIZATION_ID = ? ";
/**
* Selects attributes of a definition, given the definition Id.
*/
private static final String SELECT_ATTRIBUTES_SQL =
"select ID, NAME, TYPE, VALUE, CASCADE_ATTRIBUTE from ATTRIBUTE "
+ "where DEFINITION_ID = ? ";
/**
* Maps a row of a {@link ResultSet} to a {@link Definition}.
*/
private final DefinitionRowMapper definitionRowMapper = new DefinitionRowMapper();
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
public Definition getDefinition(String name, Locale locale) {
List