@Override public Integer run(@NotNull final DBSession session) { return countTableRows(session, tableName); } });
protected void zapSchemaInternally(final ConnectionInfo connectionInfo) { performCommandOrMetaQueryCommands(scriptum, "ZapSchema"); }
protected void ensureNoTableOrView4(final Object[] params) { performMetaQueryCommands(scriptum, "EnsureNoTableOrViewMetaQuery", params); }
@Override public void performCommandOrMetaQueryCommands(@NotNull final Scriptum scriptum, @NotNull final String operationName) { if (scriptum.findText(operationName + "Command") != null) { performCommand(scriptum, operationName + "Command"); } else if (scriptum.findText(operationName + "MetaQuery") != null) { performMetaQueryCommands(scriptum, operationName + "MetaQuery"); } else { throw new IllegalArgumentException(format( "The scriptum has no operation %sCommand or %sMetaQuery", operationName, operationName)); } }
@Override public void performCommand(@NotNull final DBTransaction transaction, @NotNull final Scriptum scriptum, @NotNull final String commandName) { final SqlCommand command = scriptum.command(commandName); performCommand(transaction, command); }
@Override public void performScript(@NotNull final Scriptum scriptum, @NotNull final String scriptName) { final SqlScript script = scriptum.script(scriptName); performScript(script); }
@Override public void ensureNoTableOrView(final String... names) { final String[][] namePacks = Collects.splitArrayPer(names, 4); for (String[] namePack : namePacks) { Object[] params; if (namePack.length == 4) { params = namePack; } else { params = new String[4]; System.arraycopy(namePack, 0, params, 0, namePack.length); Arrays.fill(params, namePack.length, 4, ""); } ensureNoTableOrView4(params); } }
@Override public void zapSchema() { final ConnectionInfo connectionInfo = db.getConnectionInfo(); final String schemaName = connectionInfo.schemaName; if (schemaName != null && schemasNotToZap.contains(schemaName)) throw new DBProtectionException(format("The schema %s must not be zapped", schemaName), "zapSchema"); zapSchemaInternally(connectionInfo); }
@Override public void performCommand(@NotNull final Scriptum scriptum, @NotNull final String commandName) { final SqlCommand command = scriptum.command(commandName); performCommand(command); }
@Override public void performScript(final String... commands) { if (commands == null || commands.length == 0) return; SqlScriptBuilder b = new SqlScriptBuilder(); for (String c : commands) b.add(c); performScript(b.build()); }
@Override public void performCommand(@NotNull final String commandText) { final SqlCommand command = new SqlCommand(commandText); performCommand(command); }
@Override public void performMetaQueryCommands(@NotNull final Scriptum scriptum, @NotNull final String metaQueryName, final Object... params) { final SqlQuery<List<String>> metaQuery = scriptum.query(metaQueryName, listOf(oneOf(String.class))); performMetaQueryCommands(metaQuery, params); }
@Override public void performCommand(@NotNull final DBTransaction transaction, @NotNull final String commandText) { final SqlCommand command = new SqlCommand(commandText); performCommand(transaction, command); }