public String getCreateTableXML(TriggerHistory triggerHistory, TriggerRouter triggerRouter) { Table table = getTable(triggerHistory, true); String targetTableName = triggerRouter.getRouter().getTargetTableName(); if (StringUtils.isNotBlank(targetTableName)) { table.setName(targetTableName); } Database db = new Database(); setDatabaseName(triggerRouter, db); db.addTable(table); StringWriter buffer = new StringWriter(); DatabaseXmlUtil.write(db, buffer); // TODO: remove when these bugs are fixed in DdlUtils String xml = buffer.toString().replaceAll("'", ""); xml = xml.replaceAll("default=\"empty_blob\\(\\) *\"", ""); xml = xml.replaceAll("unique name=\"PRIMARY\"", "unique name=\"PRIMARYINDEX\""); // on postgres, this is a "text" column xml = xml.replaceAll("type=\"VARCHAR\" size=\"2147483647\"", "type=\"LONGVARCHAR\""); xml = xml.replaceAll("type=\"BINARY\" size=\"2147483647\"", "type=\"LONGVARBINARY\""); return xml; }
String attributeValue = parser.getAttributeValue(i); if ("name".equalsIgnoreCase(attributeName)) { table.setName(attributeValue);
String attributeValue = parser.getAttributeValue(i); if (attributeName.equalsIgnoreCase("entity")) { table.setName(attributeValue); } else if (attributeName.equalsIgnoreCase("catalog")) { table.setCatalog(attributeValue);
table.setName(tableName); table.setType(type);
protected Table toAuditTable(Table table) { Table auditTable = table.copy(); String tableName = table.getName(); if (!FormatUtils.isMixedCase(tableName)) { tableName = tableName.toUpperCase(); } auditTable.setName(String.format("%s_AUDIT", tableName)); Column[] columns = auditTable.getColumns(); auditTable.removeAllColumns(); auditTable.addColumn(new Column(COLUMN_AUDIT_ID, true, Types.BIGINT, 0, 0)); auditTable.addColumn(new Column(COLUMN_AUDIT_TIME, false, Types.TIMESTAMP, 0, 0)); auditTable.addColumn(new Column(COLUMN_AUDIT_EVENT, false, Types.CHAR, 1, 0)); for (Column column : columns) { column.setRequired(false); column.setPrimaryKey(false); column.setAutoIncrement(false); auditTable.addColumn(column); } auditTable.removeAllForeignKeys(); auditTable.removeAllIndices(); engine.getDatabasePlatform().alterCaseToMatchDatabaseDefaultCase(auditTable); return auditTable; }
table.setName(router.getTargetTableName());
public boolean start(Table table) { /* * in the case when the target schema or catalog is set then we need to * use the previous schema or catalog to look up the table locally. */ this.currentTable = platform.getTableFromCache(table.getOldCatalog(), table.getOldSchema(), table.getName(), false); this.currentTable = currentTable.copyAndFilterColumns(table.getColumnNames(), table.getPrimaryKeyColumnNames(), true); /* * restore the schema and catalog from the passed in table because they * might have not been originally set, but were set when looking up the table locally */ this.currentTable.setSchema(table.getSchema()); this.currentTable.setCatalog(table.getCatalog()); this.currentTable.setName(table.getName()); return true; }