All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.etlunit.feature.database.DatabaseImplementation Maven / Gradle / Ivy

There is a newer version: 1.6.9
Show newest version
package org.etlunit.feature.database;

import org.etlunit.TestExecutionError;
import org.etlunit.parser.ETLTestMethod;
import org.etlunit.parser.ETLTestOperation;
import org.etlunit.parser.ETLTestValueObject;

import java.io.File;
import java.sql.Connection;
import java.util.List;

public interface DatabaseImplementation {
	data_format getDataFormatForExtract(ETLTestValueObject operands);

	enum operation {
		executeSql,
		createDatabase,
		completeDatabaseInitialization,
		prepareDatabase
	}

	enum data_format
	{
		delimited(".delimited"),
		sql(".sql"),
		bin(".bin"),
		raw("");

		private final String extension;

		private data_format(String extension) {
			this.extension = extension;
		}

		public String getExtension()
		{
			return extension;
		}
	}

	interface BaseRequest
	{
		String getMode();
		DatabaseConnection getConnection();
		ETLTestMethod getTestMethod();
	}

	interface InitializeRequest extends BaseRequest
	{
		File resolveSchemaReference(String ddlRef);
	}

	interface PrepareRequest extends BaseRequest
	{
		ETLTestMethod getTestMethod();
	}

	interface DataBaseRequest extends BaseRequest
	{
		String getPackage();
		String getSchema();
		ETLTestOperation getTestOperation();
	}

	interface ExecuteRequest extends DataBaseRequest
	{
		String getSource();
	}

	interface ExtractRequest extends ExecuteRequest
	{
		enum column_list_mode {
			includes,
			excludes,
			none
		}

		enum source_mode {
			table,
			sql
		}

		column_list_mode getColumnListMode();
		List getColumnList();
		File getTarget(data_format format);
		File getTargetMetaData(String type, String extension);
		source_mode getSourceMode();
		String getDataFileColumnDelimter();
		String getDataFileRowDelimter();
	}

	interface StageRequest extends DataBaseRequest
	{
		File getSource(data_format format);
		File getSourceMetaData(String type, String extension);
		String getTargetTable();
		String getDataFileColumnDelimter();
		String getDataFileRowDelimter();
	}

	interface OperationRequest
	{
		StageRequest getStageRequest() throws UnsupportedOperationException;
		ExtractRequest getExtractRequest() throws UnsupportedOperationException;
		InitializeRequest getInitializeRequest() throws UnsupportedOperationException;
		PrepareRequest getPrepareRequest() throws UnsupportedOperationException;
		ExecuteRequest getExecuteRequest() throws UnsupportedOperationException;
	}

	enum database_state
	{
		pass,
		fail
	}

	database_state getDatabaseState(DatabaseConnection dc, String mode);

	String getImplementationId();

	Object processOperation(operation op, OperationRequest request) throws UnsupportedOperationException;

	int DEFAULT_ID = 0;

	Connection getConnection(DatabaseConnection dc, String mode) throws TestExecutionError;
	Connection getConnection(DatabaseConnection dc, String mode, int identifier) throws TestExecutionError;

	void prepareConnectionForInsert(Connection connection, RelationalDataSet target, String mode) throws Exception;

	void returnConnection(Connection conn, DatabaseConnection dc, String mode, int id) throws TestExecutionError;
	String getDefaultSchema(DatabaseConnection dc, String mode);

	void dispose();
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy