diff options
Diffstat (limited to 'plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/delta/DBFieldDelta.java')
-rw-r--r-- | plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/delta/DBFieldDelta.java | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/delta/DBFieldDelta.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/delta/DBFieldDelta.java index 3cff743278..53cd451df4 100644 --- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/delta/DBFieldDelta.java +++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/delta/DBFieldDelta.java @@ -12,7 +12,10 @@ package org.eclipse.net4j.internal.db.ddl.delta; import org.eclipse.net4j.db.DBType; import org.eclipse.net4j.db.ddl.IDBField; +import org.eclipse.net4j.db.ddl.IDBSchema; +import org.eclipse.net4j.db.ddl.IDBTable; import org.eclipse.net4j.db.ddl.delta.IDBDelta; +import org.eclipse.net4j.db.ddl.delta.IDBDeltaVisitor; import org.eclipse.net4j.db.ddl.delta.IDBFieldDelta; import org.eclipse.net4j.db.ddl.delta.IDBPropertyDelta; import org.eclipse.net4j.util.ObjectUtil; @@ -37,35 +40,38 @@ public final class DBFieldDelta extends DBTableElementDelta implements IDBFieldD DBType oldType = oldField == null ? null : oldField.getType(); if (!ObjectUtil.equals(type, oldType)) { - addPropertyDelta(new DBPropertyDelta<DBType>("type", IDBPropertyDelta.Type.STRING, type, oldType)); + addPropertyDelta(new DBPropertyDelta<DBType>(TYPE_PROPERTY, IDBPropertyDelta.Type.STRING, type, oldType)); } Integer precision = field == null ? null : field.getPrecision(); Integer oldPrecision = oldField == null ? null : oldField.getPrecision(); if (!ObjectUtil.equals(precision, oldPrecision)) { - addPropertyDelta(new DBPropertyDelta<Integer>("precision", IDBPropertyDelta.Type.INTEGER, precision, oldPrecision)); + addPropertyDelta(new DBPropertyDelta<Integer>(PRECISION_PROPERTY, IDBPropertyDelta.Type.INTEGER, precision, + oldPrecision)); } Integer scale = field == null ? null : field.getScale(); Integer oldScale = oldField == null ? null : oldField.getScale(); if (!ObjectUtil.equals(scale, oldScale)) { - addPropertyDelta(new DBPropertyDelta<Integer>("scale", IDBPropertyDelta.Type.INTEGER, scale, oldScale)); + addPropertyDelta(new DBPropertyDelta<Integer>(SCALE_PROPERTY, IDBPropertyDelta.Type.INTEGER, scale, oldScale)); } Boolean notNull = field == null ? null : field.isNotNull(); Boolean oldNotNull = oldField == null ? null : oldField.isNotNull(); if (!ObjectUtil.equals(notNull, oldNotNull)) { - addPropertyDelta(new DBPropertyDelta<Boolean>("notNull", IDBPropertyDelta.Type.BOOLEAN, notNull, oldNotNull)); + addPropertyDelta(new DBPropertyDelta<Boolean>(NOT_NULL_PROPERTY, IDBPropertyDelta.Type.BOOLEAN, notNull, + oldNotNull)); } Integer position = oldField == null ? null : field.getPosition(); Integer oldPosition = oldField == null ? null : oldField.getPosition(); if (!ObjectUtil.equals(position, oldPosition)) { - addPropertyDelta(new DBPropertyDelta<Integer>("position", IDBPropertyDelta.Type.INTEGER, position, oldPosition)); + addPropertyDelta(new DBPropertyDelta<Integer>(POSITION_PROPERTY, IDBPropertyDelta.Type.INTEGER, position, + oldPosition)); } } @@ -80,4 +86,20 @@ public final class DBFieldDelta extends DBTableElementDelta implements IDBFieldD { return Type.FIELD; } + + public void accept(IDBDeltaVisitor visitor) + { + visitor.visit(this); + } + + public IDBField getElement(IDBSchema schema) + { + IDBTable table = getParent().getElement(schema); + if (table == null) + { + return null; + } + + return table.getField(getName()); + } } |