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

schemacrawler.spring.boot.utils.SchemaCrawlerOptionBuilder Maven / Gradle / Ivy

The newest version!
package schemacrawler.spring.boot.utils;

import java.util.Arrays;
import java.util.List;

import schemacrawler.schemacrawler.IncludeAll;
import schemacrawler.schemacrawler.InclusionRule;
import schemacrawler.schemacrawler.InfoLevel;
import schemacrawler.schemacrawler.SchemaCrawlerOptionsBuilder;
import schemacrawler.schemacrawler.SchemaInfoLevel;
import schemacrawler.schemacrawler.SchemaInfoLevelBuilder;
/**
 * SchemaCrawler utility methods.
 * @author vindell
 */
public final class SchemaCrawlerOptionBuilder {

	public static SchemaCrawlerOptionsBuilder custom(SchemaInfoLevel schemaInfoLevel) {
		// Set what details are required in the schema - this affects the time taken to crawl the schema
		return SchemaCrawlerOptionsBuilder.builder().withSchemaInfoLevel(schemaInfoLevel);
	}

	public static SchemaCrawlerOptionsBuilder detailed() {
		// Set what details are required in the schema - this affects the time taken to crawl the schema
		SchemaInfoLevel schemaInfoLevel = InfoLevel.detailed.toSchemaInfoLevel();
		return SchemaCrawlerOptionsBuilder.builder().withSchemaInfoLevel(schemaInfoLevel);
	}

	public static SchemaCrawlerOptionsBuilder maximum() {
		// Set what details are required in the schema - this affects the time taken to crawl the schema
		SchemaInfoLevel schemaInfoLevel = InfoLevel.maximum.toSchemaInfoLevel();
		return SchemaCrawlerOptionsBuilder.builder().withSchemaInfoLevel(schemaInfoLevel);
	}

	public static SchemaCrawlerOptionsBuilder minimum() {
		// Set what details are required in the schema - this affects the time taken to crawl the schema
		SchemaInfoLevel schemaInfoLevel = InfoLevel.minimum.toSchemaInfoLevel();
		return SchemaCrawlerOptionsBuilder.builder().withSchemaInfoLevel(schemaInfoLevel);
	}
	
	public static SchemaCrawlerOptionsBuilder standard() {
		// Set what details are required in the schema - this affects the time taken to crawl the schema
		SchemaInfoLevel schemaInfoLevel = InfoLevel.standard.toSchemaInfoLevel();
		return SchemaCrawlerOptionsBuilder.builder().withSchemaInfoLevel(schemaInfoLevel);
	}
	
	/**
	 * Sets the schema inclusion rule.
	 * Sets table types requested for output from a collection of table types. For example: TABLE,VIEW,SYSTEM_TABLE,GLOBAL TEMPORARY,ALIAS,SYNONYM
	 * @author 		: vindell
	 * @param schemaInclusionRule Schema inclusion rule
	 * @param tableTypes Collection of table types. Can be null if all supported table types are requested.
	 * @return {@link SchemaCrawlerOptionsBuilder} instance
	 */
	public static SchemaCrawlerOptionsBuilder tablecolumns(InclusionRule schemaInclusionRule, String ... tableTypes ) {
		
		// Set what details are required in the schema - this affects the time taken to crawl the schema
		SchemaInfoLevelBuilder schemaInfoLevelBuilder = SchemaInfoLevelBuilder.builder()
				.setRetrieveAdditionalColumnAttributes(true)
				.setRetrieveAdditionalTableAttributes(true)
				.setRetrieveColumnDataTypes(true)
				.setRetrieveIndexes(false)
				.setRetrieveRoutineColumns(true)
				.setRetrieveTableColumns(true)
				.setRetrieveUserDefinedColumnDataTypes(true)
				.setRetrieveViewInformation(true);
		
		List tableTypeList = (tableTypes == null || tableTypes.length == 0) ? Arrays.asList("BASE TABLE", "TABLE", "VIEW") : Arrays.asList(tableTypes);
		
		return SchemaCrawlerOptionsBuilder.builder()
				.tableTypes(tableTypeList)
				.includeTables(new IncludeAll())
				.includeAllRoutines()
				.includeColumns(new IncludeAll())
				.includeSchemas(schemaInclusionRule)
				.withSchemaInfoLevel(schemaInfoLevelBuilder);
	}

	private SchemaCrawlerOptionBuilder() {
		// Prevent instantiation
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy