/**
 * 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 com.cloudera.sqoop.mapreduce.db;

import org.apache.hadoop.conf.Configuration;

/**
 * A container for configuration property names for jobs with DB input/output.
 *
 * The job can be configured using the static methods in this class,
 * {@link DBInputFormat}, and {@link DBOutputFormat}.
 * Alternatively, the properties can be set in the configuration with proper
 * values.
 *
 * @see DBConfiguration#configureDB(Configuration, String, String, String,
 * String)
 * @see DBInputFormat#setInput(Job, Class, String, String)
 * @see DBInputFormat#setInput(Job, Class, String, String, String, String...)
 * @see DBOutputFormat#setOutput(Job, String, String...)
 *
 * @deprecated use org.apache.sqoop.mapreduce.db.DBConfiguration instead.
 * @see org.apache.sqoop.mapreduce.db.DBConfiguration
 */
public class DBConfiguration
  extends org.apache.sqoop.mapreduce.db.DBConfiguration {

  /** The JDBC Driver class name. */
  public static final String DRIVER_CLASS_PROPERTY =
      org.apache.sqoop.mapreduce.db.DBConfiguration.DRIVER_CLASS_PROPERTY;

  /** JDBC Database access URL. */
  public static final String URL_PROPERTY =
      org.apache.sqoop.mapreduce.db.DBConfiguration.URL_PROPERTY;

  /** User name to access the database. */
  public static final String USERNAME_PROPERTY =
      org.apache.sqoop.mapreduce.db.DBConfiguration.USERNAME_PROPERTY;

  /** Password to access the database. */
  public static final String PASSWORD_PROPERTY =
      org.apache.sqoop.mapreduce.db.DBConfiguration.PASSWORD_PROPERTY;

  /** Fetch size. */
  public static final String FETCH_SIZE =
      org.apache.sqoop.mapreduce.db.DBConfiguration.FETCH_SIZE;

  /** Input table name. */
  public static final String INPUT_TABLE_NAME_PROPERTY =
      org.apache.sqoop.mapreduce.db.DBConfiguration.INPUT_TABLE_NAME_PROPERTY;

  /** Field names in the Input table. */
  public static final String INPUT_FIELD_NAMES_PROPERTY =
      org.apache.sqoop.mapreduce.db.DBConfiguration.INPUT_FIELD_NAMES_PROPERTY;

  /** WHERE clause in the input SELECT statement. */
  public static final String INPUT_CONDITIONS_PROPERTY =
      org.apache.sqoop.mapreduce.db.DBConfiguration.INPUT_CONDITIONS_PROPERTY;

  /** ORDER BY clause in the input SELECT statement. */
  public static final String INPUT_ORDER_BY_PROPERTY =
      org.apache.sqoop.mapreduce.db.DBConfiguration.INPUT_ORDER_BY_PROPERTY;

  /** Whole input query, exluding LIMIT...OFFSET. */
  public static final String INPUT_QUERY =
      org.apache.sqoop.mapreduce.db.DBConfiguration.INPUT_QUERY;

  /** Input query to get the count of records. */
  public static final String INPUT_COUNT_QUERY =
      org.apache.sqoop.mapreduce.db.DBConfiguration.INPUT_COUNT_QUERY;

  /** Input query to get the max and min values of the jdbc.input.query. */
  public static final String INPUT_BOUNDING_QUERY =
      org.apache.sqoop.mapreduce.db.DBConfiguration.INPUT_BOUNDING_QUERY;

  /** Class name implementing DBWritable which will hold input tuples. */
  public static final String INPUT_CLASS_PROPERTY =
      org.apache.sqoop.mapreduce.db.DBConfiguration.INPUT_CLASS_PROPERTY;

  /** Output table name. */
  public static final String OUTPUT_TABLE_NAME_PROPERTY =
      org.apache.sqoop.mapreduce.db.DBConfiguration.OUTPUT_TABLE_NAME_PROPERTY;

  /** Field names in the Output table. */
  public static final String OUTPUT_FIELD_NAMES_PROPERTY =
      org.apache.sqoop.mapreduce.db.DBConfiguration.OUTPUT_FIELD_NAMES_PROPERTY;

  /** Number of fields in the Output table. */
  public static final String OUTPUT_FIELD_COUNT_PROPERTY =
      org.apache.sqoop.mapreduce.db.DBConfiguration.OUTPUT_FIELD_COUNT_PROPERTY;

  /**
   * Sets the DB access related fields in the {@link Configuration}.
   * @param conf the configuration
   * @param driverClass JDBC Driver class name
   * @param dbUrl JDBC DB access URL
   * @param userName DB access username
   * @param passwd DB access passwd
   * @param fetchSize DB fetch size
   */
  public static void configureDB(Configuration conf, String driverClass,
      String dbUrl, String userName, String passwd, Integer fetchSize) {

    org.apache.sqoop.mapreduce.db.DBConfiguration.configureDB(
        conf, driverClass, dbUrl, userName, passwd, fetchSize);
  }

  /**
   * Sets the DB access related fields in the JobConf.
   * @param job the job
   * @param driverClass JDBC Driver class name
   * @param dbUrl JDBC DB access URL
   * @param fetchSize DB fetch size
   */
  public static void configureDB(Configuration job, String driverClass,
      String dbUrl, Integer fetchSize) {
    org.apache.sqoop.mapreduce.db.DBConfiguration.configureDB(job, driverClass,
        dbUrl, fetchSize);
  }

  /**
   * Sets the DB access related fields in the {@link Configuration}.
   * @param conf the configuration
   * @param driverClass JDBC Driver class name
   * @param dbUrl JDBC DB access URL
   * @param userName DB access username
   * @param passwd DB access passwd
   */
  public static void configureDB(Configuration conf, String driverClass,
      String dbUrl, String userName, String passwd) {
    org.apache.sqoop.mapreduce.db.DBConfiguration.configureDB(conf, driverClass,
        dbUrl, userName, passwd);
  }

  /**
   * Sets the DB access related fields in the JobConf.
   * @param job the job
   * @param driverClass JDBC Driver class name
   * @param dbUrl JDBC DB access URL.
   */
  public static void configureDB(Configuration job, String driverClass,
      String dbUrl) {
    org.apache.sqoop.mapreduce.db.DBConfiguration.configureDB(job, driverClass,
        dbUrl);
  }

  public DBConfiguration(Configuration job) {
    super(job);
  }
}

