if (policy.shouldUseLocalTime()) { method.addLine(policyName + ".useLocalTime();"); } else {
/** * PUBLIC: * Whenever a historical record is logically deleted (updated) or inserted, * the end and start fields respectively will be set to this value. */ public Object getCurrentTime(AbstractSession session) { if (shouldUseLocalTime()) { return new java.sql.Timestamp(System.currentTimeMillis()); } if (shouldUseDatabaseTime()) { AbstractSession readSession = session.getSessionForClass(getDescriptor().getJavaClass()); while (readSession.isUnitOfWork()) { readSession = ((UnitOfWorkImpl)readSession).getParent().getSessionForClass(getDescriptor().getJavaClass()); } return readSession.getDatasourceLogin().getDatasourcePlatform().getTimestampFromServer(session, readSession.getName()); } return null; }
/** * PUBLIC: * Whenever a historical record is logically deleted (updated) or inserted, * the end and start fields respectively will be set to this value. */ public Object getCurrentTime(AbstractSession session) { if (shouldUseLocalTime()) { return new java.sql.Timestamp(System.currentTimeMillis()); } if (shouldUseDatabaseTime()) { AbstractSession readSession = session.getSessionForClass(getDescriptor().getJavaClass()); while (readSession.isUnitOfWork()) { readSession = ((UnitOfWorkImpl)readSession).getParent().getSessionForClass(getDescriptor().getJavaClass()); } return readSession.getDatasourceLogin().getDatasourcePlatform().getTimestampFromServer(session, readSession.getName()); } return null; }
/** * PUBLIC: * Whenever a historical record is logically deleted (updated) or inserted, * the end and start fields respectively will be set to this value. */ public Object getCurrentTime(AbstractSession session) { if (shouldUseLocalTime()) { return new java.sql.Timestamp(System.currentTimeMillis()); } if (shouldUseDatabaseTime()) { AbstractSession readSession = session.getSessionForClass(getDescriptor().getJavaClass()); while (readSession.isUnitOfWork()) { readSession = ((UnitOfWorkImpl)readSession).getParent().getSessionForClass(getDescriptor().getJavaClass()); } return readSession.getDatasourceLogin().getDatasourcePlatform().getTimestampFromServer(session, readSession.getName()); } return null; }
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();"); } }
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();"); } }