/**
 * Copyright 2016 Otto (GmbH & Co KG)
 *
 * Licensed 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.schedoscope.export.jdbc.outputschema;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

import org.apache.hadoop.conf.Configuration;

/**
 * Contains the derby specific mapping of the column types.
 *
 */
public class DerbySchema extends AbstractSchema {

	protected static final String JDBC_DRIVER_NAME = "org.apache.derby.jdbc.EmbeddedDriver";

	@SuppressWarnings("serial")
	private static final Map<String, String> columnTypeMapping = Collections
			.unmodifiableMap(new HashMap<String, String>() {
				{
					put("string", "varchar(32000)");
					put("boolean", "boolean");
					put("int", "int");
					put("long", "bigint");
					put("bigint", "bigint");
					put("double", "double");
					put("float", "float");
					put("tinyint", "int");
				}
			});

	@SuppressWarnings("serial")
	private static final Map<String, String> preparedStatementTypeMapping = Collections
			.unmodifiableMap(new HashMap<String, String>() {
				{
					put("varchar(32000)", "string");
					put("boolean", "boolean");
					put("int", "int");
					put("bigint", "long");
					put("double", "double");
					put("float", "float");
					put("tinyint", "int");
				}
			});

	/**
	 * The constructor to initialize the Derby dialect.
	 *
	 * @param conf
	 *            The Hadoop configuration object.
	 */
	public DerbySchema(Configuration conf) {

		super(conf);
		this.conf.set(Schema.JDBC_DRIVER_CLASS, JDBC_DRIVER_NAME);
	}

	@Override
	public Map<String, String> getColumnTypeMapping() {
		return columnTypeMapping;
	}

	@Override
	public Map<String, String> getPreparedStatementTypeMapping() {
		return preparedStatementTypeMapping;
	}
}

@@ -722,16 +722,45 @@
 til.Map;
+%0Aimport java.util.Properties;
 %0A%0Aimport
@@ -2285,11 +2285,103 @@
 ping;%0A%09%7D
+%0A%0A%09@Override%0A%09protected Properties getConnectionProperties() %7B%0A%09%09return new Properties();%0A%09%7D
 %0A%7D%0A

fix unit tests, there is no user and pass for derby db