Skip to content

Commit

Permalink
Various typographic edits
Browse files Browse the repository at this point in the history
  • Loading branch information
safris committed Nov 27, 2023
1 parent c96ed82 commit f7fcc0e
Show file tree
Hide file tree
Showing 15 changed files with 232 additions and 153 deletions.
276 changes: 183 additions & 93 deletions ddlx/src/main/java/org/jaxdb/ddlx/Compiler.java

Large diffs are not rendered by default.

33 changes: 0 additions & 33 deletions ddlx/src/main/java/org/jaxdb/ddlx/DDLx.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import org.jaxdb.www.ddlx_0_6.xLygluGCXAA.$Clob;
import org.jaxdb.www.ddlx_0_6.xLygluGCXAA.$Column;
import org.jaxdb.www.ddlx_0_6.xLygluGCXAA.$ColumnIndex;
import org.jaxdb.www.ddlx_0_6.xLygluGCXAA.$Columns;
import org.jaxdb.www.ddlx_0_6.xLygluGCXAA.$Date;
import org.jaxdb.www.ddlx_0_6.xLygluGCXAA.$Datetime;
import org.jaxdb.www.ddlx_0_6.xLygluGCXAA.$Decimal;
Expand All @@ -43,8 +42,6 @@
import org.jaxdb.www.ddlx_0_6.xLygluGCXAA.$Float;
import org.jaxdb.www.ddlx_0_6.xLygluGCXAA.$ForeignKeyComposite;
import org.jaxdb.www.ddlx_0_6.xLygluGCXAA.$ForeignKeyUnary;
import org.jaxdb.www.ddlx_0_6.xLygluGCXAA.$IndexesIndex;
import org.jaxdb.www.ddlx_0_6.xLygluGCXAA.$IndexesIndex.Unique$;
import org.jaxdb.www.ddlx_0_6.xLygluGCXAA.$Int;
import org.jaxdb.www.ddlx_0_6.xLygluGCXAA.$Named;
import org.jaxdb.www.ddlx_0_6.xLygluGCXAA.$PrimaryKey;
Expand Down Expand Up @@ -262,36 +259,6 @@ public DDLx(final URL url) throws IOException, SAXException, TransformerExceptio
}
}

// FIXME: Remove this.
public boolean isUnique(final Table table, final $Named column) {
final Table.Constraints constraints = table.getConstraints();
if (constraints != null) {
final BindingList<$Columns> uniques = constraints.getUnique();
if (uniques != null) {
for (int i = 0, i$ = uniques.size(); i < i$; ++i) { // [RA]
final $Columns unique = uniques.get(i);
if (unique.getColumn().size() == 1 && column.getName$().text().equals(unique.getColumn(0).getName$().text()))
return true;
}
}
}

final Table.Indexes tableIndexes = table.getIndexes();
if (tableIndexes != null) {
final BindingList<$IndexesIndex> indexes = tableIndexes.getIndex();
if (indexes != null) {
for (int i = 0, i$ = indexes.size(); i < i$; ++i) { // [RA]
final $IndexesIndex index = indexes.get(i);
final Unique$ unique$ = index.getUnique$();
if (unique$ != null && unique$.text() && index.getColumn().size() == 1 && column.getName$().text().equals(index.getColumn(0).getName$().text()))
return true;
}
}
}

return false;
}

public void recreate(final Connection connection) throws GeneratorExecutionException, SQLException {
Schemas.recreate(connection, this);
}
Expand Down
2 changes: 1 addition & 1 deletion ddlx/src/main/java/org/jaxdb/ddlx/Statement.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ abstract class Statement {
}

String getSql() {
return this.sql;
return sql;
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion ddlx/src/main/java/org/jaxdb/ddlx/StatementBatch.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@ public void writeOutput(final File file) throws IOException {
}

public LinkedHashSet<Statement> getStatements() {
return this.statements;
return statements;
}
}
2 changes: 1 addition & 1 deletion ddlx/src/main/java/org/jaxdb/ddlx/dt.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public Column(final T value) {
}

public T get() {
return this.value;
return value;
}

@Override
Expand Down
4 changes: 2 additions & 2 deletions ddlx/src/main/java/org/jaxdb/vendor/DbVendorCompiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
import java.util.function.Supplier;
import java.util.zip.CRC32;

import org.jaxdb.www.ddlx_0_6.xLygluGCXAA;
import org.jaxdb.www.ddlx_0_6.xLygluGCXAA.$IndexType;
import org.jaxdb.www.ddlx_0_6.xLygluGCXAA.$Integer;
import org.jaxdb.www.ddlx_0_6.xLygluGCXAA.$Name;
import org.jaxdb.www.ddlx_0_6.xLygluGCXAA.$Triggers;
import org.jaxdb.www.ddlx_0_6.xLygluGCXAA.Schema;

Expand Down Expand Up @@ -66,7 +66,7 @@ protected final StringBuilder getConstraintName(final String prefix, final Strin
return constraintName;
}

protected final StringBuilder getConstraintName(final String prefix, final Schema.Table table, final xLygluGCXAA.$Name references, final int[] columnIndexes) {
protected final StringBuilder getConstraintName(final String prefix, final Schema.Table table, final $Name references, final int[] columnIndexes) {
final StringBuilder builder = new StringBuilder(table.getName$().text());
if (references != null)
builder.append('_').append(references.text());
Expand Down
6 changes: 3 additions & 3 deletions ddlx/src/main/java/org/jaxdb/vendor/Dialect.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@
import org.libj.lang.Strings;
import org.libj.util.DecimalFormatter;
import org.openjax.xml.api.CharacterDatas;
import org.w3.www._2001.XMLSchema.yAA;
import org.w3.www._2001.XMLSchema.yAA.$AnyType;

public abstract class Dialect extends DbVendorCompiler {
// FIXME: Remove this hack!
private abstract static class BindingProxy extends Binding {
protected static yAA.$AnyType<?> owner(final Binding binding) {
protected static $AnyType<?> owner(final Binding binding) {
return Binding.owner(binding);
}
}
Expand All @@ -62,7 +62,7 @@ public static StringBuilder getTypeName(final StringBuilder b, final $Enum colum
if (column.getTemplate$() != null)
return b.append("ty_").append(column.getTemplate$().text());

final yAA.$AnyType<?> owner = BindingProxy.owner(column);
final $AnyType<?> owner = BindingProxy.owner(column);
if (owner instanceof Schema)
return b.append("ty_").append(column.getName$().text());

Expand Down
2 changes: 1 addition & 1 deletion jaxdb-maven-plugin/src/main/java/org/jaxdb/SqlXsdMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Configuration extends JaxDbMojo<SqlXsdProduce>.Configuration {
}

LinkedHashSet<URL> getXsds() {
return this.xsds;
return xsds;
}
}

Expand Down
3 changes: 1 addition & 2 deletions jaxdb-maven-plugin/src/test/java/org/jaxdb/jsql/KeyTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,13 @@
import java.time.LocalTime;
import java.util.function.Supplier;

import org.jaxdb.jsql.data.Column;
import org.junit.Test;
import org.libj.lang.ObjectUtil;

public class KeyTest {
private static class MockTable extends data.Table {
MockTable() {
super(true, false, new Column[1], new Column[1], new Column[0], new Column[0]);
super(true, false, new data.Column[1], new data.Column[1], new data.Column[0], new data.Column[0]);
}

@Override
Expand Down
3 changes: 1 addition & 2 deletions jsql/src/main/java/org/jaxdb/jsql/Condition.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import java.sql.SQLException;
import java.util.ArrayList;

import org.jaxdb.jsql.data.Table;
import org.jaxdb.vendor.DbVendor;
import org.libj.util.DiscreteTopology;

Expand Down Expand Up @@ -184,7 +183,7 @@ void write(final Compiler compiler, final PreparedStatement statement, final boo
}
}

Condition(final data.Table owner, final boolean mutable, final OnModify<? extends Table> onModify) {
Condition(final data.Table owner, final boolean mutable, final OnModify<? extends data.Table> onModify) {
super(owner, mutable, onModify);
}

Expand Down
12 changes: 6 additions & 6 deletions jsql/src/main/java/org/jaxdb/jsql/ExpressionImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,17 @@ final void compile(final Compilation compilation, final boolean isExpression) th

@Override
LocalTime evaluate(final LocalTime a) {
return this.b.toTimeInterval().addTo(a);
return b.toTimeInterval().addTo(a);
}

@Override
LocalDate evaluate(final LocalDate a) {
return this.b.toDateInterval().addTo(a);
return b.toDateInterval().addTo(a);
}

@Override
LocalDateTime evaluate(final LocalDateTime a) {
return this.b.addTo(a);
return b.addTo(a);
}
}

Expand All @@ -70,17 +70,17 @@ final void compile(final Compilation compilation, final boolean isExpression) th

@Override
LocalTime evaluate(final LocalTime a) {
return this.b.toTimeInterval().subtractFrom(a);
return b.toTimeInterval().subtractFrom(a);
}

@Override
LocalDate evaluate(final LocalDate a) {
return this.b.toDateInterval().subtractFrom(a);
return b.toDateInterval().subtractFrom(a);
}

@Override
LocalDateTime evaluate(final LocalDateTime a) {
return this.b.subtractFrom(a);
return b.subtractFrom(a);
}
}

Expand Down
2 changes: 1 addition & 1 deletion jsql/src/main/java/org/jaxdb/jsql/Schema.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ private static ConnectionFactory toConnectionFactory(final DataSource dataSource

public Connector connect(final ConnectionFactory connectionFactory, final boolean isPrepared) {
this.isPrepared = isPrepared;
return this.connector = new Connector(this, connectionFactory, isPrepared);
return connector = new Connector(this, connectionFactory, isPrepared);
}

public Connector connect(final DataSource dataSource, final boolean isPrepared) {
Expand Down
33 changes: 28 additions & 5 deletions jsql/src/main/java/org/jaxdb/jsql/Transaction.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ private Isolation(final int level) {
}

public int getLevel() {
return this.level;
return level;
}
}

Expand Down Expand Up @@ -132,10 +132,21 @@ protected void onNotify(final OnNotifyCallbackList onNotifyCallbackList) {
}
}

/**
* Commits all changes made since the previous commit/rollback, releases any database locks currently held by this
* {@link Transaction}'s {@link Connection}, and returns a {@link NotifiableBatchResult}.
*
* @return The {@link NotifiableBatchResult} of the commit.
* @throws SQLException If a database access error occurs, this method is called while participating in a distributed transaction,
* or this method is called on a closed connection.
*/
public NotifiableBatchResult commit() throws SQLException {
if (connection == null)
if (closed)
throw new SQLRecoverableException("Connection closed");

if (connection == null)
return NotifiableBatchResult.EMPTY;

try {
connection.commit();
if (callbacks != null)
Expand All @@ -152,10 +163,20 @@ public NotifiableBatchResult commit() throws SQLException {
}
}

/**
* Undoes all changes made in the current transaction and releases any database locks currently held by this {@link Transaction}'s
* {@link Connection}.
*
* @throws SQLException If a database access error occurs, this method is called while participating in a distributed transaction,
* or this method is called on a closed connection.
*/
public void rollback() throws SQLException {
if (connection == null)
if (closed)
throw new SQLRecoverableException("Connection closed");

if (connection == null)
return;

try {
connection.rollback();
if (callbacks != null)
Expand All @@ -172,18 +193,20 @@ public void rollback() throws SQLException {
* encountered during the rollback operation, the thrown exception is added as a {@link Throwable#addSuppressed(Throwable)
* suppressed exception} to the provided {@link Throwable}.
*
* @implNote This method should be used only when auto-commit mode has been disabled.
* @param t The {@link Throwable} to which any thrown exceptions should be added as {@link Throwable#addSuppressed(Throwable)
* suppressed exceptions}.
* @return The {@code boolean} value representing the success of the rollback.
* @throws NullPointerException If {@code t} is null.
*/
public boolean rollback(final Throwable t) {
if (connection == null) {
if (closed) {
assertNotNull(t).addSuppressed(new SQLRecoverableException("Connection closed"));
return false;
}

if (connection == null)
return false;

try {
connection.rollback();
if (callbacks != null)
Expand Down
3 changes: 1 addition & 2 deletions jsql/src/main/java/org/jaxdb/jsql/generator/TableModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
import org.jaxdb.www.ddlx_0_6.xLygluGCXAA.$Enum;
import org.jaxdb.www.ddlx_0_6.xLygluGCXAA.$Float;
import org.jaxdb.www.ddlx_0_6.xLygluGCXAA.$ForeignKeyComposite;
import org.jaxdb.www.ddlx_0_6.xLygluGCXAA.$ForeignKeyComposite.Column;
import org.jaxdb.www.ddlx_0_6.xLygluGCXAA.$ForeignKeyUnary;
import org.jaxdb.www.ddlx_0_6.xLygluGCXAA.$Int;
import org.jaxdb.www.ddlx_0_6.xLygluGCXAA.$Integer;
Expand Down Expand Up @@ -210,7 +209,7 @@ public IndexType put(final ColumnModels key, IndexType value) {
final TableModel referenceTable = schemaModel.tableNameToTableModel.get(foreignKeyComposite.getReferences$().text());
final ColumnModels columns = new ColumnModels(this, 2);
final ColumnModels referenceColumns = new ColumnModels(this, 2);
final BindingList<Column> foreignKeyColumns = foreignKeyComposite.getColumn();
final BindingList<$ForeignKeyComposite.Column> foreignKeyColumns = foreignKeyComposite.getColumn();
final int j$ = foreignKeyColumns.size();
for (int j = 0; j < j$; ++j) { // [RA]
final $ForeignKeyComposite.Column foreignKeyColumn = foreignKeyColumns.get(j);
Expand Down
2 changes: 2 additions & 0 deletions jsql/src/main/java/org/jaxdb/jsql/statement.java
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,8 @@ public abstract static class NotifiableResult extends Result {
}

public static class NotifiableBatchResult extends NotifiableResult {
static final NotifiableBatchResult EMPTY = new NotifiableBatchResult(0, null);

private final ArrayList<OnNotifyCallbackList> onNotifyCallbackLists;
private String[] sessionIds;

Expand Down

0 comments on commit f7fcc0e

Please sign in to comment.