/** * PUBLIC: */ public List<String> getHistoryTableNames() { List<String> names = new ArrayList(getHistoricalTables().size()); for (DatabaseTable table : getHistoricalTables()) { names.add(table.getQualifiedName()); } return names; }
/** * PUBLIC: */ public List<String> getHistoryTableNames() { List<String> names = new ArrayList(getHistoricalTables().size()); for (DatabaseTable table : getHistoricalTables()) { names.add(table.getQualifiedName()); } return names; }
/** * PUBLIC: */ public Vector getHistoryTableNames() { Vector names = new Vector(getHistoricalTables().size()); for (Enumeration enumtr = getHistoricalTables().elements(); enumtr.hasMoreElements();) { HistoricalDatabaseTable table = (HistoricalDatabaseTable)enumtr.nextElement(); names.addElement(table.getQualifiedName());// / getSecretName(). } return names; }
/** * PUBLIC: * Use to specify the names of the mirroring historical tables. * <p> * Explicitly states that <code>sourceTableName</code> is mirrored by history table * <code>historyTableName</code>. * The order in which tables are added with descriptor.addTableName() * should still match the order in which mirroring historical tables are * added with descriptor.addMirroringHistoryTableName(). */ public void addHistoryTableName(String sourceTableName, String historyTableName) { if ((sourceTableName == null) || sourceTableName.equals("")) { addHistoryTableName(historyTableName); } HistoricalDatabaseTable table = new HistoricalDatabaseTable(sourceTableName); table.setHistoricalName(historyTableName); // Note that the equality check is only on sourceTableName, not historyTableName. int index = getHistoricalTables().indexOf(table); if (index == -1) { getHistoricalTables().add(table); } else { getHistoricalTables().set(index, table); } }
/** * PUBLIC: * Use to specify the names of the mirroring historical tables. * <p> * Explicitly states that <code>sourceTableName</code> is mirrored by history table * <code>historyTableName</code>. * The order in which tables are added with descriptor.addTableName() * should still match the order in which mirroring historical tables are * added with descriptor.addMirroringHistoryTableName(). */ public void addHistoryTableName(String sourceTableName, String historyTableName) { if ((sourceTableName == null) || sourceTableName.equals("")) { addHistoryTableName(historyTableName); } HistoricalDatabaseTable table = new HistoricalDatabaseTable(sourceTableName); table.setHistoricalName(historyTableName); // Note that the equality check is only on sourceTableName, not historyTableName. int index = getHistoricalTables().indexOf(table); if (index == -1) { getHistoricalTables().add(table); } else { getHistoricalTables().set(index, table); } }
/** * PUBLIC: * Use to specify the names of the mirroring historical tables. * <p> * Assumes that the order in which tables are added with descriptor.addTableName() * matches the order in which mirroring historical tables are added with * descriptor.addHistoryTableName(). */ public void addHistoryTableName(String name) { HistoricalDatabaseTable table = new HistoricalDatabaseTable(""); table.setHistoricalName(name); getHistoricalTables().add(table); }
/** * PUBLIC: * Use to specify the names of the mirroring historical tables. * <p> * Assumes that the order in which tables are added with descriptor.addTableName() * matches the order in which mirroring historical tables are added with * descriptor.addHistoryTableName(). */ public void addHistoryTableName(String name) { HistoricalDatabaseTable table = new HistoricalDatabaseTable(""); table.setHistoricalName(name); getHistoricalTables().add(table); }
/** * PUBLIC: * Use to specify the names of the mirroring historical tables. * <p> * Assumes that the order in which tables are added with descriptor.addTableName() * matches the order in which mirroring historical tables are added with * descriptor.addHistoryTableName(). */ public void addHistoryTableName(String name) { HistoricalDatabaseTable table = new HistoricalDatabaseTable(""); table.setHistoricalName(name); getHistoricalTables().add(table); }
/** * INTERNAL: Check that the qualifiers on the historical tables are * properly set. * <p>A similar method exists on ClassDescriptor. */ protected void verifyTableQualifiers(DatasourcePlatform platform) { HistoricalDatabaseTable table; DatabaseTable scratchTable; Enumeration tableEnumeration; String tableQualifier = platform.getTableQualifier(); if (tableQualifier.length() == 0) { return; } tableEnumeration = getHistoricalTables().elements(); while (tableEnumeration.hasMoreElements()) { table = (HistoricalDatabaseTable)tableEnumeration.nextElement(); // Build a scratch table to see if history table name has a qualifier. scratchTable = new DatabaseTable(table.getQualifiedName()); if (scratchTable.getTableQualifier().length() == 0) { scratchTable.setTableQualifier(tableQualifier); table.setHistoricalName(scratchTable.getQualifiedNameDelimited(platform)); } } }
/** * INTERNAL: Check that the qualifiers on the historical tables are * properly set. * <p>A similar method exists on ClassDescriptor. */ protected void verifyTableQualifiers(DatasourcePlatform platform) { String tableQualifier = platform.getTableQualifier(); if (tableQualifier.length() == 0) { return; } for (DatabaseTable table : getHistoricalTables()) { // Build a scratch table to see if history table name has a qualifier. DatabaseTable scratchTable = new DatabaseTable(table.getQualifiedName()); if (scratchTable.getTableQualifier().length() == 0) { scratchTable.setTableQualifier(tableQualifier); ((HistoricalDatabaseTable)table).setHistoricalName(scratchTable.getQualifiedNameDelimited(platform)); } } }
/** * INTERNAL: Check that the qualifiers on the historical tables are * properly set. * <p>A similar method exists on ClassDescriptor. */ protected void verifyTableQualifiers(DatasourcePlatform platform) { String tableQualifier = platform.getTableQualifier(); if (tableQualifier.length() == 0) { return; } for (DatabaseTable table : getHistoricalTables()) { // Build a scratch table to see if history table name has a qualifier. DatabaseTable scratchTable = new DatabaseTable(table.getQualifiedName()); if (scratchTable.getTableQualifier().length() == 0) { scratchTable.setTableQualifier(tableQualifier); ((HistoricalDatabaseTable)table).setHistoricalName(scratchTable.getQualifiedNameDelimited(platform)); } } }
/** * INTERNAL: */ public Vector getOwnedTables() { if (getDescriptor() == null) { if (getAdditionalTables() != null){ Vector tables = new Vector(); addAdditionalTablesToTableList(tables); return tables; } return null; } else { if (getDescriptor().isAggregateDescriptor()) { return null; } else { if ((getDescriptor().getHistoryPolicy() != null) && (getAsOfClause().getValue() != null)) { return getDescriptor().getHistoryPolicy().getHistoricalTables(); } Vector tables = new Vector(); tables.addAll(getDescriptor().getTables()); addAdditionalTablesToTableList(tables); return tables; } } }
/** * INTERNAL: * If we ever get in the circumstance of a manual query key * to an aggregate, then we can assume that the owner of that * aggregate isn't participating (and even if it is, we can't * know which node it is, so *DO* use the aggregate's parents tables */ public List<DatabaseTable> getOwnedTables() { if (getDescriptor() == null) { return null; } else { if ((getDescriptor().getHistoryPolicy() != null) && (getAsOfClause().getValue() != null)) { return getDescriptor().getHistoryPolicy().getHistoricalTables(); } return getDescriptor().getTables(); } }
/** * INTERNAL: * If we ever get in the circumstance of a manual query key * to an aggregate, then we can assume that the owner of that * aggregate isn't participating (and even if it is, we can't * know which node it is, so *DO* use the aggregate's parents tables */ public List<DatabaseTable> getOwnedTables() { if (getDescriptor() == null) { return null; } else { if ((getDescriptor().getHistoryPolicy() != null) && (getAsOfClause().getValue() != null)) { return getDescriptor().getHistoryPolicy().getHistoricalTables(); } return getDescriptor().getTables(); } }
/** * INTERNAL: * If we ever get in the circumstance of a manual query key * to an aggregate, then we can assume that the owner of that * aggregate isn't participating (and even if it is, we can't * know which node it is, so *DO* use the aggregate's parents tables */ public Vector getOwnedTables() { if (getDescriptor() == null) { return null; } else { if ((getDescriptor().getHistoryPolicy() != null) && (getAsOfClause().getValue() != null)) { return getDescriptor().getHistoryPolicy().getHistoricalTables(); } return getDescriptor().getTables(); } }
/** * INTERNAL: * Performs a logical insert into the historical schema. Direct * collections and many to many mappings are maintained through the session * events. */ public void mappingLogicalInsert(DataModifyQuery originalQuery, AbstractRecord arguments, AbstractSession session) { DataModifyQuery historyQuery = new DataModifyQuery(); SQLInsertStatement historyStatement = new SQLInsertStatement(); DatabaseTable histTable = getHistoricalTables().get(0); historyStatement.setTable(histTable); AbstractRecord modifyRow = originalQuery.getModifyRow().clone(); AbstractRecord translationRow = arguments.clone(); // Start could be the version field in timestamp locking. if (!modifyRow.containsKey(getStart())) { Object time = getCurrentTime(session); modifyRow.add(getStart(), time); translationRow.add(getStart(), time); } historyQuery.setSQLStatement(historyStatement); historyQuery.setModifyRow(modifyRow); historyStatement.setModifyRow(modifyRow); session.executeQuery(historyQuery, translationRow); }
/** * INTERNAL: * Performs a logical insert into the historical schema. Direct * collections and many to many mappings are maintained through the session * events. */ public void mappingLogicalInsert(DataModifyQuery originalQuery, AbstractRecord arguments, AbstractSession session) { DataModifyQuery historyQuery = new DataModifyQuery(); SQLInsertStatement historyStatement = new SQLInsertStatement(); DatabaseTable histTable = (DatabaseTable)getHistoricalTables().elementAt(0); historyStatement.setTable(histTable); AbstractRecord modifyRow = (AbstractRecord)originalQuery.getModifyRow().clone(); AbstractRecord translationRow = (AbstractRecord)arguments.clone(); // Start could be the version field in timestamp locking. if (!modifyRow.containsKey(getStart())) { Object time = getCurrentTime(session); modifyRow.add(getStart(), time); translationRow.add(getStart(), time); } historyQuery.setSQLStatement(historyStatement); historyQuery.setModifyRow(modifyRow); historyStatement.setModifyRow(modifyRow); session.executeQuery(historyQuery, translationRow); }
/** * INTERNAL: * Performs a logical insert into the historical schema. Direct * collections and many to many mappings are maintained through the session * events. */ public void mappingLogicalInsert(DataModifyQuery originalQuery, AbstractRecord arguments, AbstractSession session) { DataModifyQuery historyQuery = new DataModifyQuery(); SQLInsertStatement historyStatement = new SQLInsertStatement(); DatabaseTable histTable = getHistoricalTables().get(0); historyStatement.setTable(histTable); AbstractRecord modifyRow = originalQuery.getModifyRow().clone(); AbstractRecord translationRow = arguments.clone(); // Start could be the version field in timestamp locking. if (!modifyRow.containsKey(getStart())) { Object time = getCurrentTime(session); modifyRow.add(getStart(), time); translationRow.add(getStart(), time); } historyQuery.setSQLStatement(historyStatement); historyQuery.setModifyRow(modifyRow); historyStatement.setModifyRow(modifyRow); session.executeQuery(historyQuery, translationRow); }
protected void addHistoryPolicyLines(NonreflectiveMethodDefinition method, HistoryPolicy policy, String policyName) { method.addLine(""); method.addLine("// History Policy"); method.addLine("HistoryPolicy " + policyName + " = new HistoryPolicy();"); for (DatabaseTable table : policy.getHistoricalTables()) { String sourceName = null; if (table.getTableQualifier().equals("")) { sourceName = table.getName(); } else { sourceName = table.getTableQualifier() + "." + table.getName(); } String historyName = table.getQualifiedName(); method.addLine(policyName + ".addHistoryTableName(\"" + sourceName + "\", \"" + historyName + "\");"); } for (DatabaseField field : policy.getStartFields()) { method.addLine(policyName + ".addStartFieldName(\"" + field.getQualifiedName() + "\");"); // Field classifications don't seem to be supported in workbench integration. //method.addLine(policyName + ".setStartFieldType(\"" + field.getQualifiedName() + "\", " + field.getType().getName() + ".class);"); } for (DatabaseField field : policy.getEndFields()) { method.addLine(policyName + ".addEndFieldName(\"" + field.getQualifiedName() + "\");"); //method.addLine(policyName + ".setEndFieldType(\"" + field.getQualifiedName() + "\", " + field.getType().getName() + ".class);"); } method.addLine(policyName + ".setShouldHandleWrites(" + (policy.shouldHandleWrites() ? "true" : "false") + ");"); if (policy.shouldUseLocalTime()) { method.addLine(policyName + ".useLocalTime();"); } else { method.addLine(policyName + ".useDatabaseTime();"); } }
/** * INTERNAL: * Performs a logical delete (update) on the historical schema. Direct * collections and many to many mappings are maintained through the session * events. */ public void mappingLogicalDelete(ModifyQuery originalQuery, AbstractRecord arguments, AbstractSession session) { SQLDeleteStatement originalStatement = (SQLDeleteStatement)originalQuery.getSQLStatement(); DataModifyQuery historyQuery = new DataModifyQuery(); SQLUpdateStatement historyStatement = new SQLUpdateStatement(); DatabaseTable histTable = getHistoricalTables().get(0); historyStatement.setTable(histTable); Expression whereClause = (Expression)originalStatement.getWhereClause().clone(); DatabaseField endField = getEnd(); whereClause = whereClause.getBuilder().getField(endField).isNull().and(whereClause); historyStatement.setWhereClause(whereClause); AbstractRecord modifyRow = new DatabaseRecord(); AbstractRecord translationRow = arguments.clone(); Object time = getCurrentTime(session); modifyRow.add(getEnd(), time); translationRow.add(getEnd(), time); historyStatement.setModifyRow(modifyRow); historyQuery.setSQLStatement(historyStatement); historyQuery.setModifyRow(modifyRow); session.executeQuery(historyQuery, translationRow); } }