[#6991] Updated depending features:

- XMLGenerator
- XMLDatabase
- DSLContext.meta(InformationSchema)
- DSLContext.informationSchema(...)
This commit is contained in:
lukaseder 2018-01-04 17:07:16 +01:00
parent cbf028aced
commit 132a1ef71e
10 changed files with 61 additions and 25 deletions

View File

@ -106,7 +106,7 @@ public class XMLGenerator extends AbstractGenerator {
String catalogName = c.getOutputName();
if (hasNonDefaultCatalogs)
is.getCatalogs().add(new Catalog().withCatalogName(catalogName));
is.getCatalogs().add(new Catalog().withCatalogName(catalogName).withComment(c.getComment()));
for (SchemaDefinition s : c.getSchemata()) {
String schemaName = s.getOutputName();
@ -114,6 +114,7 @@ public class XMLGenerator extends AbstractGenerator {
Schema schema = new Schema();
schema.setCatalogName(catalogName);
schema.setSchemaName(schemaName);
schema.setComment(s.getComment());
is.getSchemata().add(schema);
@ -124,6 +125,7 @@ public class XMLGenerator extends AbstractGenerator {
table.setTableCatalog(catalogName);
table.setTableSchema(schemaName);
table.setTableName(tableName);
table.setComment(t.getComment());
is.getTables().add(table);
@ -136,6 +138,7 @@ public class XMLGenerator extends AbstractGenerator {
column.setTableSchema(schemaName);
column.setTableName(tableName);
column.setColumnName(columnName);
column.setComment(co.getComment());
column.setCharacterMaximumLength(type.getLength());
column.setColumnDefault(type.getDefaultValue());
column.setDataType(type.getType());
@ -159,6 +162,7 @@ public class XMLGenerator extends AbstractGenerator {
index.setIndexCatalog(catalogName);
index.setIndexSchema(schemaName);
index.setIndexName(indexName);
index.setComment(i.getComment());
index.setTableCatalog(table.getCatalog().getOutputName());
index.setTableSchema(table.getSchema().getOutputName());
index.setTableName(table.getOutputName());
@ -195,6 +199,7 @@ public class XMLGenerator extends AbstractGenerator {
constraint.setConstraintSchema(schemaName);
constraint.setConstraintName(constraintName);
constraint.setConstraintType(u.isPrimaryKey() ? PRIMARY_KEY : UNIQUE);
constraint.setComment(u.getComment());
constraint.setTableCatalog(table.getCatalog().getOutputName());
constraint.setTableSchema(table.getSchema().getOutputName());
constraint.setTableName(table.getOutputName());
@ -230,6 +235,7 @@ public class XMLGenerator extends AbstractGenerator {
tc.setConstraintSchema(schemaName);
tc.setConstraintName(constraintName);
tc.setConstraintType(FOREIGN_KEY);
tc.setComment(f.getComment());
tc.setTableCatalog(table.getCatalog().getOutputName());
tc.setTableSchema(table.getSchema().getOutputName());
tc.setTableName(table.getOutputName());
@ -272,6 +278,7 @@ public class XMLGenerator extends AbstractGenerator {
constraint.setConstraintSchema(schemaName);
constraint.setConstraintName(constraintName);
constraint.setConstraintType(CHECK);
constraint.setComment(ch.getComment());
constraint.setTableCatalog(table.getCatalog().getOutputName());
constraint.setTableSchema(table.getSchema().getOutputName());
constraint.setTableName(table.getOutputName());
@ -287,6 +294,7 @@ public class XMLGenerator extends AbstractGenerator {
sequence.setSequenceCatalog(catalogName);
sequence.setSequenceSchema(schemaName);
sequence.setSequenceName(sequenceName);
sequence.setComment(se.getComment());
sequence.setCharacterMaximumLength(type.getLength());
sequence.setDataType(type.getType());
sequence.setNumericPrecision(type.getPrecision());
@ -326,6 +334,7 @@ public class XMLGenerator extends AbstractGenerator {
routine.setRoutineName(r.getName());
routine.setSpecificName(specificName);
routine.setComment(r.getComment());
if (r.getReturnValue() == null) {
routine.setRoutineType(RoutineType.PROCEDURE);
@ -354,6 +363,7 @@ public class XMLGenerator extends AbstractGenerator {
parameter.setSpecificName(specificName);
parameter.setOrdinalPosition(i++);
parameter.setParameterName(p.getName());
parameter.setComment(p.getComment());
boolean in = r.getInParameters().contains(p);
boolean out = r.getOutParameters().contains(p);

View File

@ -50,7 +50,11 @@ public abstract class AbstractIndexDefinition extends AbstractDefinition impleme
private List<IndexColumnDefinition> indexColumns;
public AbstractIndexDefinition(SchemaDefinition schema, String name, TableDefinition table, boolean unique) {
super(schema.getDatabase(), schema, name, "");
this(schema, name, table, unique, "");
}
public AbstractIndexDefinition(SchemaDefinition schema, String name, TableDefinition table, boolean unique, String comment) {
super(schema.getDatabase(), schema, name, comment);
this.table = table;
this.unique = unique;

View File

@ -60,7 +60,11 @@ public class DefaultParameterDefinition
}
public DefaultParameterDefinition(RoutineDefinition routine, String name, int position, DataTypeDefinition type, boolean isDefaulted, boolean isUnnamed) {
super(routine, name, position, type, null);
this(routine, name, position, type, isDefaulted, isUnnamed, null);
}
public DefaultParameterDefinition(RoutineDefinition routine, String name, int position, DataTypeDefinition type, boolean isDefaulted, boolean isUnnamed, String comment) {
super(routine, name, position, type, comment);
this.isDefaulted = isDefaulted;
this.isUnnamed = isUnnamed;

View File

@ -45,6 +45,10 @@ public class DefaultSequenceDefinition
implements SequenceDefinition {
public DefaultSequenceDefinition(SchemaDefinition schema, String name, DataTypeDefinition type) {
super(schema, name, -1, type, null);
this(schema, name, type, null);
}
public DefaultSequenceDefinition(SchemaDefinition schema, String name, DataTypeDefinition type, String comment) {
super(schema, name, -1, type, comment);
}
}

View File

@ -290,7 +290,7 @@ public class XMLDatabase extends AbstractDatabase {
final Name name = name(i.getIndexCatalog(), i.getIndexSchema(), i.getTableName(), i.getIndexName());
IndexDefinition index = new AbstractIndexDefinition(schema, i.getIndexName(), table, Boolean.TRUE.equals(i.isIsUnique())) {
IndexDefinition index = new AbstractIndexDefinition(schema, i.getIndexName(), table, Boolean.TRUE.equals(i.isIsUnique()), i.getComment()) {
private final List<IndexColumnDefinition> indexColumns;
{
@ -441,7 +441,7 @@ public class XMLDatabase extends AbstractDatabase {
List<SchemaDefinition> result = new ArrayList<SchemaDefinition>();
for (Schema schema : info().getSchemata()) {
result.add(new SchemaDefinition(this, schema.getSchemaName(), null));
result.add(new SchemaDefinition(this, schema.getSchemaName(), schema.getComment()));
}
return result;
@ -466,7 +466,7 @@ public class XMLDatabase extends AbstractDatabase {
(String) null
);
result.add(new DefaultSequenceDefinition(schema, sequence.getSequenceName(), type));
result.add(new DefaultSequenceDefinition(schema, sequence.getSequenceName(), type, sequence.getComment()));
}
}
@ -481,7 +481,7 @@ public class XMLDatabase extends AbstractDatabase {
if (getInputSchemata().contains(table.getTableSchema())) {
SchemaDefinition schema = getSchema(table.getTableSchema());
result.add(new XMLTableDefinition(schema, info(), table));
result.add(new XMLTableDefinition(schema, info(), table, table.getComment()));
}
}
@ -523,7 +523,7 @@ public class XMLDatabase extends AbstractDatabase {
if (getInputSchemata().contains(schemaName)) {
SchemaDefinition schema = getSchema(schemaName);
result.add(new XMLRoutineDefinition(schema, null, info(), routine));
result.add(new XMLRoutineDefinition(schema, null, info(), routine, routine.getComment()));
}
}
}

View File

@ -71,7 +71,7 @@ public class XMLPackageDefinition extends AbstractPackageDefinition {
String routineName = defaultIfBlank(routine.getSpecificPackage(), routine.getRoutinePackage());
if (getName().equals(routineName)) {
result.add(new XMLRoutineDefinition(getSchema(), this, info, routine));
result.add(new XMLRoutineDefinition(getSchema(), this, info, routine, routine.getComment()));
}
}

View File

@ -62,7 +62,11 @@ public class XMLRoutineDefinition extends AbstractRoutineDefinition {
private final InformationSchema info;
public XMLRoutineDefinition(SchemaDefinition schema, PackageDefinition pkg, InformationSchema info, Routine routine) {
super(schema, pkg, routine.getRoutineName(), "", overload(info, routine));
this(schema, pkg, info, routine, "");
}
public XMLRoutineDefinition(SchemaDefinition schema, PackageDefinition pkg, InformationSchema info, Routine routine, String comment) {
super(schema, pkg, routine.getRoutineName(), comment, overload(info, routine));
this.info = info;
@ -145,7 +149,8 @@ public class XMLRoutineDefinition extends AbstractRoutineDefinition {
parameter.getOrdinalPosition(),
type,
!StringUtils.isBlank(parameter.getParameterDefault()),
StringUtils.isBlank(parameter.getParameterName())
StringUtils.isBlank(parameter.getParameterName()),
parameter.getComment()
);
switch (parameter.getParameterMode()) {

View File

@ -63,7 +63,11 @@ public class XMLTableDefinition extends AbstractTableDefinition {
private final Table table;
public XMLTableDefinition(SchemaDefinition schema, InformationSchema info, Table table) {
super(schema, table.getTableName(), "");
this(schema, info, table, "");
}
public XMLTableDefinition(SchemaDefinition schema, InformationSchema info, Table table, String comment) {
super(schema, table.getTableName(), comment);
this.info = info;
this.table = table;
@ -97,7 +101,7 @@ public class XMLTableDefinition extends AbstractTableDefinition {
unbox(column.getOrdinalPosition()),
type,
column.getIdentityGeneration() != null,
""
column.getComment()
));
}
}

View File

@ -182,6 +182,7 @@ final class InformationSchemaExport {
if (!StringUtils.isBlank(c.getName())) {
ic.setCatalogName(c.getName());
ic.setComment(c.getComment());
result.getCatalogs().add(ic);
}
}
@ -194,6 +195,7 @@ final class InformationSchemaExport {
if (!StringUtils.isBlank(s.getName())) {
is.setSchemaName(s.getName());
is.setComment(s.getComment());
result.getSchemata().add(is);
}
}
@ -208,6 +210,7 @@ final class InformationSchemaExport {
it.setTableSchema(t.getSchema().getName());
it.setTableName(t.getName());
it.setComment(t.getComment());
result.getTables().add(it);
Field<?>[] fields = t.fields();
@ -223,6 +226,7 @@ final class InformationSchemaExport {
ic.setTableName(t.getName());
ic.setColumnName(f.getName());
ic.setComment(f.getComment());
ic.setDataType(f.getDataType().getTypeName(configuration));
if (f.getDataType().hasLength())

View File

@ -125,7 +125,7 @@ final class InformationSchemaMetaImpl implements Meta {
// -------------------------------------------------------------------------------------------------------------
boolean hasCatalogs = false;
for (org.jooq.util.xml.jaxb.Catalog xc : meta.getCatalogs()) {
InformationSchemaCatalog ic = new InformationSchemaCatalog(xc.getCatalogName());
InformationSchemaCatalog ic = new InformationSchemaCatalog(xc.getCatalogName(), xc.getComment());
catalogs.add(ic);
catalogsByName.put(name(xc.getCatalogName()), ic);
hasCatalogs = true;
@ -138,7 +138,7 @@ final class InformationSchemaMetaImpl implements Meta {
// [#6662] This is kept for backwards compatibility reasons
if (!hasCatalogs) {
InformationSchemaCatalog ic = new InformationSchemaCatalog(xs.getCatalogName());
InformationSchemaCatalog ic = new InformationSchemaCatalog(xs.getCatalogName(), null);
if (!catalogs.contains(ic)) {
catalogs.add(ic);
@ -154,7 +154,7 @@ final class InformationSchemaMetaImpl implements Meta {
continue schemaLoop;
}
InformationSchemaSchema is = new InformationSchemaSchema(xs.getSchemaName(), catalog);
InformationSchemaSchema is = new InformationSchemaSchema(xs.getSchemaName(), catalog, xs.getComment());
schemas.add(is);
schemasByName.put(name(xs.getCatalogName(), xs.getSchemaName()), is);
}
@ -171,7 +171,7 @@ final class InformationSchemaMetaImpl implements Meta {
continue tableLoop;
}
InformationSchemaTable it = new InformationSchemaTable(xt.getTableName(), schema);
InformationSchemaTable it = new InformationSchemaTable(xt.getTableName(), schema, xt.getComment());
tables.add(it);
tablesByName.put(name(xt.getTableCatalog(), xt.getTableSchema(), xt.getTableName()), it);
}
@ -216,7 +216,8 @@ final class InformationSchemaMetaImpl implements Meta {
AbstractTable.createField(
xc.getColumnName(),
type(typeName, length, precision, scale, nullable),
table
table,
xc.getComment()
);
}
@ -526,8 +527,8 @@ final class InformationSchemaMetaImpl implements Meta {
*/
private static final long serialVersionUID = 87038321849045492L;
InformationSchemaCatalog(String name) {
super(name);
InformationSchemaCatalog(String name, String comment) {
super(name, comment);
}
@Override
@ -543,8 +544,8 @@ final class InformationSchemaMetaImpl implements Meta {
*/
private static final long serialVersionUID = 7290709749127378187L;
public InformationSchemaSchema(String name, Catalog catalog) {
super(name, catalog);
public InformationSchemaSchema(String name, Catalog catalog, String comment) {
super(name, catalog, comment);
}
@Override
@ -570,8 +571,8 @@ final class InformationSchemaMetaImpl implements Meta {
final List<ForeignKey<Record, Record>> foreignKeys = new ArrayList<ForeignKey<Record, Record>>();
final List<Index> indexes = new ArrayList<Index>();
public InformationSchemaTable(String name, Schema schema) {
super(name, schema);
public InformationSchemaTable(String name, Schema schema, String comment) {
super(name, schema, null, null, comment);
}
@Override