org.hotrod.metadata.TableDataSetMetadata Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hotrod-generator Show documentation
Show all versions of hotrod-generator Show documentation
HotRod is an ORM for Java, Spring and SpringBoot.
The newest version!
package org.hotrod.metadata;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.hotrod.config.AbstractDAOTag;
import org.hotrod.config.ClassicFKNavigationTag;
import org.hotrod.config.ColumnTag;
import org.hotrod.config.EnumTag;
import org.hotrod.config.HotRodConfigTag;
import org.hotrod.config.HotRodFragmentConfigTag;
import org.hotrod.config.QueryMethodTag;
import org.hotrod.config.SelectGenerationTag;
import org.hotrod.config.SelectMethodTag;
import org.hotrod.config.SequenceMethodTag;
import org.hotrod.config.TableTag;
import org.hotrod.config.VersionControlColumnTag;
import org.hotrod.config.ViewTag;
import org.hotrod.database.DatabaseAdapter;
import org.hotrod.exceptions.ControlledException;
import org.hotrod.exceptions.InvalidConfigurationFileException;
import org.hotrod.exceptions.InvalidIdentifierException;
import org.hotrod.exceptions.UncontrolledException;
import org.hotrod.exceptions.UnresolvableDataTypeException;
import org.hotrod.generator.ColumnsRetriever;
import org.hotrod.generator.ParameterRenderer;
import org.hotrod.generator.SelectMetadataCache;
import org.hotrod.generator.mybatisspring.DataSetLayout;
import org.hotrod.identifiers.ObjectId;
import org.hotrod.utils.ClassPackage;
import org.hotrod.utils.ColumnsPrefixGenerator;
import org.nocrala.tools.database.tartarus.core.DatabaseObjectId;
import org.nocrala.tools.database.tartarus.core.JdbcColumn;
import org.nocrala.tools.database.tartarus.core.JdbcForeignKey;
import org.nocrala.tools.database.tartarus.core.JdbcKey;
import org.nocrala.tools.database.tartarus.core.JdbcKeyColumn;
import org.nocrala.tools.database.tartarus.core.JdbcTable;
public class TableDataSetMetadata implements DataSetMetadata, Serializable {
private static final long serialVersionUID = 1L;
private static final Logger log = LogManager.getLogger(TableDataSetMetadata.class);
protected transient JdbcTable t;
protected transient HotRodConfigTag config;
protected transient DatabaseAdapter adapter;
private AbstractDAOTag daoTag;
private TableTag parentTag;
@SuppressWarnings("unused")
private transient JdbcTable parentJdbcTable;
private TableDataSetMetadata parent;
private List cols;
private KeyMetadata pk;
private List uniqueIndexes;
private List nonPKCols;
private List importedFKs;
private List exportedFKs;
private ObjectId id;
private ClassicFKNavigationTag classicFKNavigation;
// private AutoGeneratedColumnMetadata agcm;
private VersionControlMetadata vcm;
private List sequences = new ArrayList();
private List queries = new ArrayList();
private List selects = new ArrayList();
// private SelectMetadataCache selectMetadataCache;
private List selectsMetadata;
private HotRodFragmentConfigTag fragmentConfig;
@SuppressWarnings("unused")
private ClassPackage classPackage;
private boolean isFromCurrentCatalog;
private boolean isFromCurrentSchema;
// Table constructor
protected TableDataSetMetadata(final TableTag tableTag, final JdbcTable t, final TableTag parentTag,
final JdbcTable parentJdbcTable, final DatabaseAdapter adapter, final HotRodConfigTag config,
final DataSetLayout layout, final SelectMetadataCache selectMetadataCache, final boolean isFromCurrentCatalog,
final boolean isFromCurrentSchema) throws UnresolvableDataTypeException, InvalidConfigurationFileException {
log.debug("init t=" + t.getName());
this.t = t;
this.config = config;
this.adapter = adapter;
this.daoTag = tableTag;
this.fragmentConfig = tableTag.getFragmentConfig();
this.parentTag = parentTag;
this.parentJdbcTable = parentJdbcTable;
this.parent = null;
this.classicFKNavigation = tableTag.getClassicFKNavigation();
// this.selectMetadataCache = selectMetadataCache;
this.isFromCurrentCatalog = isFromCurrentCatalog;
this.isFromCurrentSchema = isFromCurrentSchema;
ClassPackage fragmentPackage = this.fragmentConfig != null && this.fragmentConfig.getFragmentPackage() != null
? this.fragmentConfig.getFragmentPackage()
: null;
this.classPackage = layout.getDAOPrimitivePackage(fragmentPackage);
this.cols = getColumnsMetadata(this.t.getColumns(), tableTag);
this.pk = getKeyMetadata(this.t.getPk(), tableTag);
this.uniqueIndexes = new ArrayList();
for (JdbcKey k : this.t.getUniqueIndexes()) {
this.uniqueIndexes.add(getKeyMetadata(k, tableTag));
}
this.importedFKs = new ArrayList();
for (JdbcForeignKey fk : this.t.getImportedFks()) {
log.debug("imported FK: " + renderFK(t, fk));
KeyMetadata ikm;
TableTag remoteTableTag = this.config.getTableTag(fk.getRemoteTable());
if (remoteTableTag != null) {
ikm = getKeyMetadata(fk.getRemoteKey(), remoteTableTag);
} else {
EnumTag remoteEnumTag = this.config.getEnumTag(fk.getRemoteTable());
if (remoteEnumTag != null) {
ikm = getKeyMetadata(fk.getRemoteKey(), remoteEnumTag);
} else {
throw new RuntimeException(
"Could not find the remote table or enum for the imported FK on table=" + t.getName());
}
}
this.importedFKs.add(new ForeignKeyMetadata(getKeyMetadata(fk.getLocalKey(), tableTag), ikm, fk.pointsToPk(),
fk.getRemoteTable()));
}
this.exportedFKs = new ArrayList();
for (JdbcForeignKey fk : this.t.getExportedFks()) {
log.debug("exported FK: " + renderExportedFK(t, fk));
KeyMetadata ekm;
TableTag remoteTableTag = this.config.getTableTag(fk.getRemoteTable());
log.debug("remoteTableTag=" + remoteTableTag);
if (remoteTableTag != null) {
ekm = getKeyMetadata(fk.getRemoteKey(), remoteTableTag);
} else {
EnumTag remoteEnumTag = this.config.getEnumTag(fk.getRemoteTable());
if (remoteEnumTag != null) {
ekm = getKeyMetadata(fk.getRemoteKey(), remoteEnumTag);
} else {
throw new RuntimeException(
"Could not find the remote table or enum for the exported FK on table=" + t.getName());
}
}
this.exportedFKs.add(new ForeignKeyMetadata(getKeyMetadata(fk.getLocalKey(), tableTag), ekm, fk.pointsToPk(),
fk.getRemoteTable()));
}
this.nonPKCols = getColumnsMetadata(this.t.getNonPkColumns(), tableTag);
this.id = tableTag.getId();
log.debug("this.t.getName()=" + this.t.getName());
VersionControlColumnTag vct = tableTag.getVersionControlColumn();
if (vct == null) {
this.vcm = null;
} else {
ColumnMetadata vcm = this.findColumnMetadata(vct);
if (vcm == null) {
String msg = "Could not find version control column with name '" + vct.getName() + "' on table '" + t.getName()
+ "'.";
throw new InvalidConfigurationFileException(vct, msg);
}
log.debug("### VERSION CONTROL COLUMN SETTING: c=" + vcm.getColumnName() + " c=" + System.identityHashCode(vcm));
vcm.setVersionControlColumn(true);
this.vcm = new VersionControlMetadata(this, vct, vcm, this.adapter);
}
this.sequences = tableTag.getSequences();
this.queries = tableTag.getQueries();
this.selects = tableTag.getSelects();
}
// Enum Constructor
protected TableDataSetMetadata(final EnumTag enumTag, final JdbcTable t, final DatabaseAdapter adapter,
final HotRodConfigTag config, final DataSetLayout layout, final SelectMetadataCache selectMetadataCache,
final boolean isFromCurrentCatalog, final boolean isFromCurrentSchema)
throws UnresolvableDataTypeException, InvalidConfigurationFileException {
this.t = t;
this.config = config;
this.adapter = adapter;
this.daoTag = enumTag;
this.fragmentConfig = enumTag.getFragmentConfig();
this.parentTag = null;
this.parentJdbcTable = null;
this.parent = null;
this.classicFKNavigation = null;
// this.selectMetadataCache = selectMetadataCache;
this.isFromCurrentCatalog = isFromCurrentCatalog;
this.isFromCurrentSchema = isFromCurrentSchema;
ClassPackage fragmentPackage = this.fragmentConfig != null && this.fragmentConfig.getFragmentPackage() != null
? this.fragmentConfig.getFragmentPackage()
: null;
this.classPackage = layout.getDAOPrimitivePackage(fragmentPackage);
this.cols = getColumnsMetadata(this.t.getColumns(), enumTag);
this.pk = null;
this.uniqueIndexes = new ArrayList();
this.importedFKs = new ArrayList();
this.exportedFKs = new ArrayList();
this.nonPKCols = getColumnsMetadata(this.t.getNonPkColumns(), enumTag);
this.id = enumTag.getId();
this.vcm = null;
this.sequences = enumTag.getSequences();
this.queries = enumTag.getQueries();
}
// View Constructor
protected TableDataSetMetadata(final ViewTag viewTag, final JdbcTable t, final DatabaseAdapter adapter,
final HotRodConfigTag config, final DataSetLayout layout, final SelectMetadataCache selectMetadataCache,
final boolean isFromCurrentCatalog, final boolean isFromCurrentSchema)
throws UnresolvableDataTypeException, InvalidConfigurationFileException {
this.t = t;
this.config = config;
this.adapter = adapter;
this.daoTag = viewTag;
this.fragmentConfig = viewTag.getFragmentConfig();
this.parentTag = null;
this.parentJdbcTable = null;
this.parent = null;
this.classicFKNavigation = null;
// this.selectMetadataCache = selectMetadataCache;
this.isFromCurrentCatalog = isFromCurrentCatalog;
this.isFromCurrentSchema = isFromCurrentSchema;
ClassPackage fragmentPackage = this.fragmentConfig != null && this.fragmentConfig.getFragmentPackage() != null
? this.fragmentConfig.getFragmentPackage()
: null;
this.classPackage = layout.getDAOPrimitivePackage(fragmentPackage);
this.cols = getColumnsMetadata(this.t.getColumns(), viewTag);
this.pk = null;
this.uniqueIndexes = new ArrayList();
for (JdbcKey k : this.t.getUniqueIndexes()) {
this.uniqueIndexes.add(getKeyMetadata(k, viewTag));
}
this.importedFKs = new ArrayList();
for (JdbcForeignKey fk : this.t.getImportedFks()) {
this.importedFKs.add(new ForeignKeyMetadata(getKeyMetadata(fk.getLocalKey(), viewTag),
getKeyMetadata(fk.getRemoteKey(), viewTag), fk.pointsToPk(), fk.getRemoteTable()));
}
this.exportedFKs = new ArrayList();
for (JdbcForeignKey fk : this.t.getExportedFks()) {
this.exportedFKs.add(new ForeignKeyMetadata(getKeyMetadata(fk.getLocalKey(), viewTag),
getKeyMetadata(fk.getRemoteKey(), viewTag), fk.pointsToPk(), fk.getRemoteTable()));
}
this.nonPKCols = getColumnsMetadata(this.t.getNonPkColumns(), viewTag);
this.id = viewTag.getId();
this.vcm = null;
this.sequences = viewTag.getSequences();
this.queries = viewTag.getQueries();
this.selects = viewTag.getSelects();
}
public void linkReferencedTableMetadata(final Set tm) throws InvalidConfigurationFileException {
// foreign keys
for (ForeignKeyMetadata fk : this.importedFKs) {
fk.linkReferencedTableMetadata(tm);
}
for (ForeignKeyMetadata fk : this.exportedFKs) {
fk.linkReferencedTableMetadata(tm);
}
// parent tables
log.debug("" + this.id + ": this.parentTag=" + this.parentTag);
this.parent = null;
if (this.parentTag != null) {
for (TableDataSetMetadata o : tm) {
if (o.getId().equals(this.parentTag.getId())) {
this.parent = o;
}
}
log.debug("" + this.id + ": parent=" + this.parent);
if (this.parent == null) {
throw new InvalidConfigurationFileException(this.daoTag,
"Could not find parent table '" + this.parentTag.getId() + "' that is extended by '" + this.id + "'.");
}
}
}
public void linkEnumMetadata(final Set enums) {
for (ForeignKeyMetadata ifk : this.importedFKs) {
log.debug("FK: " + ifk.toString());
try {
EnumDataSetMetadata em = (EnumDataSetMetadata) ifk.getRemote().getTableMetadata();
log.debug(" - em=" + em);
for (ColumnMetadata icm : ifk.getLocal().getColumns()) {
// Mark FK column
icm.setEnumMetadata(em);
// Mark dataset column
for (ColumnMetadata cm : this.cols) {
if (cm.getColumnName().equals(icm.getColumnName())) {
log.debug(" + marking column.");
cm.setEnumMetadata(em);
}
}
// Mark PK columns
// log.info("this.t.getName()=" + this.t.getName());
// log.info("this.javaName=" + this.javaName);
// log.info(" * this.pk=" + this.pk);
if (this.pk != null) {
for (ColumnMetadata cm : this.pk.getColumns()) {
if (cm.getColumnName().equals(icm.getColumnName())) {
cm.setEnumMetadata(em);
}
}
}
// Mark non-PK columns
if (this.nonPKCols != null) {
for (ColumnMetadata cm : this.nonPKCols) {
if (cm.getColumnName().equals(icm.getColumnName())) {
cm.setEnumMetadata(em);
}
}
}
// Mark Unique indexes columns
for (KeyMetadata km : this.uniqueIndexes) {
for (ColumnMetadata cm : km.getColumns()) {
if (cm.getColumnName().equals(icm.getColumnName())) {
cm.setEnumMetadata(em);
}
}
}
}
} catch (ClassCastException e) {
// FK does not point to an enum - nothing to do.
}
}
}
// Select Methods meta data gathering
@SuppressWarnings("unused")
public boolean gatherSelectsMetadataPhase1(final Metadata metadata, final ColumnsRetriever cr,
final DataSetLayout layout) throws InvalidConfigurationFileException {
this.selectsMetadata = new ArrayList();
boolean needsToRetrieveMetadata = false;
for (SelectMethodTag selectTag : this.selects) {
// SelectMethodMetadata cachedSm =
// this.selectMetadataCache.get(this.javaName, selectTag.getMethod());
SelectMethodMetadata cachedSm = null; // Do not use cache, for now.
// log.debug("[" + this.getId().getCanonicalSQLName() + "] " + selectTag.getMethod() + "() cache["
// + this.id.getCanonicalSQLName() + "]=" + cachedSm + " cache[" + this.selectMetadataCache.size() + "]");
// log.debug(" cache entries: " + this.selectMetadataCache.listNames());
if (referencesAMarkedEntity(selectTag.getReferencedEntities())) {
selectTag.markGenerate();
}
if (cachedSm != null && !selectTag.isToBeGenerated()) {
// use the cached metadata
this.selectsMetadata.add(cachedSm);
log.info(">>> [Using cache] cachedSm.metadataComplete()=" + cachedSm.metadataComplete());
} else {
// retrieve fresh metadata
needsToRetrieveMetadata = true;
SelectGenerationTag selectGenerationTag = this.config.getGenerators().getSelectedGeneratorTag()
.getSelectGeneration();
ColumnsPrefixGenerator columnsPrefixGenerator = new ColumnsPrefixGenerator(this.adapter.getUnescapedSQLCase());
SelectMethodMetadata sm;
try {
sm = new SelectMethodMetadata(metadata, cr, selectTag, this.config, selectGenerationTag,
columnsPrefixGenerator, layout, this);
} catch (InvalidIdentifierException e) {
String msg = "Invalid method name '" + selectTag.getMethod() + "': " + e.getMessage();
throw new InvalidConfigurationFileException(selectTag, msg);
}
this.selectsMetadata.add(sm);
sm.gatherMetadataPhase1();
log.debug(">>> [Fresh] sm.metadataComplete()=" + sm.metadataComplete());
}
}
return needsToRetrieveMetadata;
}
private boolean referencesAMarkedEntity(final Set referencedEntities) {
for (TableDataSetMetadata referencedEntity : referencedEntities) {
if (referencedEntity.getDaoTag().isToBeGenerated()) {
return true;
}
}
return false;
}
public void gatherSelectsMetadataPhase2(final VORegistry voRegistry)
throws ControlledException, UncontrolledException, InvalidConfigurationFileException {
log.debug("*** DataSet " + this.id.getRenderedSQLName() + ":");
for (SelectMethodMetadata sm : this.selectsMetadata) {
log.debug("*** - table-like method " + sm.getMethod() + "() sm.metadataComplete()=" + sm.metadataComplete());
if (!sm.metadataComplete()) {
log.debug("... method: " + sm.getMethod());
sm.gatherMetadataPhase2(voRegistry);
}
}
}
// Utilities
private List getColumnsMetadata(final List cols, final TableTag tableTag)
throws UnresolvableDataTypeException, InvalidConfigurationFileException {
List lcm = new ArrayList();
for (JdbcColumn c : cols) {
boolean belongsToPK = this.t.getPk() != null && keyIncludesColumn(this.t.getPk(), c);
ColumnTag columnTag = tableTag.findColumnTag(c.getName(), this.adapter);
try {
lcm.add(new ColumnMetadata(this, c, this.adapter, columnTag, false, belongsToPK, this.config.getTypeSolverTag(),
this.config.getNameSolverTag()));
} catch (InvalidIdentifierException e) {
String msg = "Invalid identifier name for column '" + c.getName() + "': " + e.getMessage();
throw new InvalidConfigurationFileException(tableTag, msg);
}
}
return lcm;
}
private List getColumnsMetadata(final List cols, final EnumTag enumTag)
throws UnresolvableDataTypeException, InvalidConfigurationFileException {
List lcm = new ArrayList();
for (JdbcColumn c : cols) {
boolean belongsToPK = this.t.getPk() != null && keyIncludesColumn(this.t.getPk(), c);
ColumnTag columnTag = enumTag.findColumnTag(c.getName(), this.adapter);
try {
lcm.add(new ColumnMetadata(this, c, this.adapter, columnTag, false, belongsToPK, this.config.getTypeSolverTag(),
this.config.getNameSolverTag()));
} catch (InvalidIdentifierException e) {
String msg = "Invalid identifier name for column '" + c.getName() + "': " + e.getMessage();
throw new InvalidConfigurationFileException(enumTag, msg);
}
}
return lcm;
}
private List getColumnsMetadata(final List cols, final ViewTag viewTag)
throws UnresolvableDataTypeException, InvalidConfigurationFileException {
List lcm = new ArrayList();
for (JdbcColumn c : cols) {
ColumnTag columnTag = viewTag.findColumnTag(c.getName(), this.adapter);
try {
lcm.add(new ColumnMetadata(this, c, this.adapter, columnTag, false, false, this.config.getTypeSolverTag(),
this.config.getNameSolverTag()));
} catch (InvalidIdentifierException e) {
String msg = "Invalid identifier name for column '" + c.getName() + "': " + e.getMessage();
throw new InvalidConfigurationFileException(viewTag, msg);
}
}
return lcm;
}
private KeyMetadata getKeyMetadata(final JdbcKey kc, final TableTag tableTag)
throws UnresolvableDataTypeException, InvalidConfigurationFileException {
if (kc == null) {
return null;
} else {
List lcm = new ArrayList();
for (JdbcKeyColumn c : kc.getKeyColumns()) {
boolean belongsToPK = this.t.getPk() != null && keyIncludesColumn(this.t.getPk(), c.getColumn());
ColumnTag columnTag = tableTag.findColumnTag(c.getColumn().getName(), this.adapter);
try {
lcm.add(new ColumnMetadata(this, c.getColumn(), this.adapter, columnTag, false, belongsToPK,
this.config.getTypeSolverTag(), this.config.getNameSolverTag()));
} catch (InvalidIdentifierException e) {
String msg = "Invalid identifier name for column '" + c.getColumn().getName() + "': " + e.getMessage();
throw new InvalidConfigurationFileException(tableTag, msg);
}
}
return new KeyMetadata(this, lcm);
}
}
private KeyMetadata getKeyMetadata(final JdbcKey kc, final EnumTag enumTag)
throws UnresolvableDataTypeException, InvalidConfigurationFileException {
if (kc == null) {
return null;
} else {
List lcm = new ArrayList();
for (JdbcKeyColumn c : kc.getKeyColumns()) {
boolean belongsToPK = this.t.getPk() != null && keyIncludesColumn(this.t.getPk(), c.getColumn());
ColumnTag columnTag = enumTag.findColumnTag(c.getColumn().getName(), this.adapter);
try {
lcm.add(new ColumnMetadata(this, c.getColumn(), this.adapter, columnTag, false, belongsToPK,
this.config.getTypeSolverTag(), this.config.getNameSolverTag()));
} catch (InvalidIdentifierException e) {
String msg = "Invalid identifier name for column '" + c.getColumn().getName() + "': " + e.getMessage();
throw new InvalidConfigurationFileException(enumTag, msg);
}
}
return new KeyMetadata(this, lcm);
}
}
private KeyMetadata getKeyMetadata(final JdbcKey kc, final ViewTag viewTag)
throws UnresolvableDataTypeException, InvalidConfigurationFileException {
if (kc == null) {
return null;
} else {
List lcm = new ArrayList();
for (JdbcKeyColumn c : kc.getKeyColumns()) {
ColumnTag columnTag = viewTag.findColumnTag(c.getColumn().getName(), this.adapter);
try {
lcm.add(new ColumnMetadata(this, c.getColumn(), this.adapter, columnTag, false, false,
this.config.getTypeSolverTag(), this.config.getNameSolverTag()));
} catch (InvalidIdentifierException e) {
String msg = "Invalid identifier name for column '" + c.getColumn().getName() + "': " + e.getMessage();
throw new InvalidConfigurationFileException(viewTag, msg);
}
}
return new KeyMetadata(this, lcm);
}
}
private boolean keyIncludesColumn(final JdbcKey key, final JdbcColumn c) {
for (JdbcKeyColumn kc : key.getKeyColumns()) {
if (kc.getColumn().getName().equals(c.getName())) {
return true;
}
}
return false;
}
private ColumnMetadata findColumnMetadata(final VersionControlColumnTag vct) {
for (ColumnMetadata m : this.cols) {
if (this.adapter.isColumnIdentifier(m.getColumnName(), vct.getName())) {
return m;
}
}
return null;
}
// Indexable
@Override
public int hashCode() {
return this.t.getDatabaseObjectId().hashCode();
}
public DatabaseObjectId getDatabaseObjectId() {
return this.t.getDatabaseObjectId();
}
@Override
public boolean equals(Object obj) {
if (obj == null)
return false;
if (this.getClass() != obj.getClass())
return false;
try {
TableDataSetMetadata other = (TableDataSetMetadata) obj;
return this.getDatabaseObjectId().equals(other.getDatabaseObjectId());
} catch (ClassCastException e) {
return false;
}
}
// Matching FKs
boolean correspondsToJdbcTable(final JdbcTable t) {
return this.t.getDatabaseObjectId().equals(t.getDatabaseObjectId());
}
// Getters
@Override
public List getSelectsMetadata() {
return selectsMetadata;
}
@Override
public AbstractDAOTag getDaoTag() {
return daoTag;
}
@Override
public List getColumns() {
return cols;
}
@Override
public List getNonPkColumns() {
return this.nonPKCols;
}
@Override
public KeyMetadata getPK() {
return this.pk;
}
@Override
public ObjectId getId() {
return this.id;
}
@Override
public TableDataSetMetadata getParentMetadata() {
return this.parent;
}
@Override
public List getUniqueIndexes() {
return this.uniqueIndexes;
}
@Override
public List getImportedFKs() {
return this.importedFKs;
}
@Override
public List getExportedFKs() {
return this.exportedFKs;
}
@Override
public List getParameters() {
return new ArrayList();
}
@Override
public List getParameterDefinitions() {
return new ArrayList();
}
@Override
public String renderSQLSentence(final ParameterRenderer parameterRenderer) {
return null;
}
@Override
public String renderXML(final ParameterRenderer parameterRenderer) {
return null;
}
@Override
public ClassicFKNavigationTag getClassicFKNavigation() {
return this.classicFKNavigation;
}
@Override
public VersionControlMetadata getVersionControlMetadata() {
return this.vcm;
}
public List getSequences() {
return sequences;
}
public List getQueries() {
return queries;
}
public boolean hasSelects() {
return !this.selects.isEmpty();
}
@Override
public HotRodFragmentConfigTag getFragmentConfig() {
return this.fragmentConfig;
}
public boolean isFromCurrentCatalog() {
return isFromCurrentCatalog;
}
public boolean isFromCurrentSchema() {
return isFromCurrentSchema;
}
// Utils
private String renderFK(JdbcTable t, JdbcForeignKey fk) {
return t.getName() + " (" + renderKey(fk.getLocalKey()) + ") references " + fk.getRemoteTable().getName() + " ("
+ renderKey(fk.getRemoteKey()) + ")";
}
private String renderExportedFK(JdbcTable t, JdbcForeignKey fk) {
return t.getName() + " (" + renderKey(fk.getLocalKey()) + ") referenced by " + fk.getRemoteTable().getName() + " ("
+ renderKey(fk.getRemoteKey()) + ")";
}
private String renderKey(JdbcKey k) {
return k.getKeyColumns().stream().map(c -> c.getColumn().getName()).collect(Collectors.joining(", "));
}
}