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

au.net.causal.maven.plugins.boxdb.db.DerbyFactory Maven / Gradle / Ivy

There is a newer version: 3.3
Show newest version
package au.net.causal.maven.plugins.boxdb.db;

import java.util.Objects;

@BoxDbBundled
public class DerbyFactory extends FileBasedDatabaseFactory
{
    public DerbyFactory()
    {
        super("derby");
    }

	@Override
	public DerbyDatabase create(BoxConfiguration boxConfiguration, ProjectConfiguration projectConfiguration, BoxContext context)
	throws BoxDatabaseException
	{
		Objects.requireNonNull(boxConfiguration, "boxConfiguration == null");
		Objects.requireNonNull(context, "context == null");

		initializeDefaults(boxConfiguration, projectConfiguration, context);

		return new DerbyDatabase(boxConfiguration, projectConfiguration, context);
	}

	protected void initializeDefaults(BoxConfiguration boxConfiguration, ProjectConfiguration projectConfiguration, BoxContext context)
	throws BoxDatabaseException
	{
	    super.initializeDefaults(boxConfiguration, projectConfiguration, context);

		if (boxConfiguration.getDatabaseVersion() == null)
			boxConfiguration.setDatabaseVersion("10.13.1.1");
		if (boxConfiguration.getDatabasePort() <= 0)
			boxConfiguration.setDatabasePort(1527);

		CollationTranslator collationTranslator = new CollationTranslator(null, this::mapCommonCollation);
		collationTranslator.processCollation(boxConfiguration);
	}
	
	private String mapCommonCollation(CommonCollation collation)
	{
		switch (collation)
		{
			case BINARY:
				return null;
			case CASE_INSENSITIVE:
				return "en_US;PRIMARY";
			default:
				throw new Error("Unknown common collation: " + collation);
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy