use of org.hibernate.tool.schema.TargetType in project hibernate-orm by hibernate.
the class SchemaManagementToolCoordinator method buildScriptTargetDescriptor.
private static JpaTargetAndSourceDescriptor buildScriptTargetDescriptor(Map configurationValues, SettingSelector settingSelector, ServiceRegistry serviceRegistry) {
final Object scriptSourceSetting = settingSelector.getScriptSourceSetting(configurationValues);
final SourceType sourceType = SourceType.interpret(settingSelector.getSourceTypeSetting(configurationValues), scriptSourceSetting != null ? SourceType.SCRIPT : SourceType.METADATA);
final boolean includesScripts = sourceType != SourceType.METADATA;
if (includesScripts && scriptSourceSetting == null) {
throw new SchemaManagementException("Schema generation configuration indicated to include CREATE scripts, but no script was specified");
}
String charsetName = (String) configurationValues.get(AvailableSettings.HBM2DDL_CHARSET_NAME);
final ScriptSourceInput scriptSourceInput = includesScripts ? Helper.interpretScriptSourceSetting(scriptSourceSetting, serviceRegistry.getService(ClassLoaderService.class), charsetName) : null;
final ScriptTargetOutput scriptTargetOutput = Helper.interpretScriptTargetSetting(settingSelector.getScriptTargetSetting(configurationValues), serviceRegistry.getService(ClassLoaderService.class), charsetName);
return new JpaTargetAndSourceDescriptor() {
@Override
public EnumSet<TargetType> getTargetTypes() {
return EnumSet.of(TargetType.SCRIPT);
}
@Override
public ScriptTargetOutput getScriptTargetOutput() {
return scriptTargetOutput;
}
@Override
public SourceType getSourceType() {
return sourceType;
}
@Override
public ScriptSourceInput getScriptSourceInput() {
return scriptSourceInput;
}
};
}
use of org.hibernate.tool.schema.TargetType in project hibernate-orm by hibernate.
the class SchemaManagementToolCoordinator method buildDatabaseTargetDescriptor.
private static JpaTargetAndSourceDescriptor buildDatabaseTargetDescriptor(Map configurationValues, SettingSelector settingSelector, ServiceRegistry serviceRegistry) {
final Object scriptSourceSetting = settingSelector.getScriptSourceSetting(configurationValues);
final SourceType sourceType = SourceType.interpret(settingSelector.getSourceTypeSetting(configurationValues), scriptSourceSetting != null ? SourceType.SCRIPT : SourceType.METADATA);
final boolean includesScripts = sourceType != SourceType.METADATA;
if (includesScripts && scriptSourceSetting == null) {
throw new SchemaManagementException("Schema generation configuration indicated to include CREATE scripts, but no script was specified");
}
final ScriptSourceInput scriptSourceInput = includesScripts ? Helper.interpretScriptSourceSetting(scriptSourceSetting, serviceRegistry.getService(ClassLoaderService.class), (String) configurationValues.get(AvailableSettings.HBM2DDL_CHARSET_NAME)) : null;
return new JpaTargetAndSourceDescriptor() {
@Override
public EnumSet<TargetType> getTargetTypes() {
return EnumSet.of(TargetType.DATABASE);
}
@Override
public ScriptTargetOutput getScriptTargetOutput() {
return null;
}
@Override
public SourceType getSourceType() {
return sourceType;
}
@Override
public ScriptSourceInput getScriptSourceInput() {
return scriptSourceInput;
}
};
}
use of org.hibernate.tool.schema.TargetType in project bw-calendar-engine by Bedework.
the class SchemaBuilderImpl method execute.
@Override
public void execute(final Properties props, final String outputFile, final boolean export, final String delimiter) throws CalFacadeException {
try {
SchemaExport se = new SchemaExport();
if (delimiter != null) {
se.setDelimiter(delimiter);
}
se.setFormat(true);
se.setHaltOnError(false);
se.setOutputFile(outputFile);
final EnumSet<TargetType> targets = EnumSet.noneOf(TargetType.class);
if (export) {
targets.add(TargetType.DATABASE);
} else {
targets.add(TargetType.SCRIPT);
}
Properties allProps = getConfiguration(props).getProperties();
final BootstrapServiceRegistry bsr = new BootstrapServiceRegistryBuilder().build();
final StandardServiceRegistryBuilder ssrBuilder = new StandardServiceRegistryBuilder(bsr);
ssrBuilder.applySettings(allProps);
se.execute(targets, SchemaExport.Action.BOTH, null, ssrBuilder.getBootstrapServiceRegistry());
} catch (Throwable t) {
throw new CalFacadeException(t);
}
}
Aggregations