public List<TriggerHistory> findTriggerHistories(String catalogName, String schemaName, String tableName) { List<TriggerHistory> listToReturn = new ArrayList<TriggerHistory>(); List<TriggerHistory> triggerHistories = getActiveTriggerHistories(); if (triggerHistories != null && triggerHistories.size() > 0) { for (TriggerHistory triggerHistory : triggerHistories) { boolean matches = true; if (StringUtils.isNotBlank(catalogName)) { matches = catalogName.equals(triggerHistory.getSourceCatalogName()); } if (matches && StringUtils.isNotBlank(schemaName)) { matches = schemaName.equals(triggerHistory.getSourceSchemaName()); } if (matches && StringUtils.isNotBlank(tableName)) { boolean ignoreCase = parameterService.is(ParameterConstants.DB_METADATA_IGNORE_CASE) && !FormatUtils.isMixedCase(tableName); matches = ignoreCase ? triggerHistory.getSourceTableName().equalsIgnoreCase(tableName) : triggerHistory.getSourceTableName().equals(tableName); } if (matches) { listToReturn.add(triggerHistory); } } } return listToReturn; }
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; }