use of org.obeonetwork.dsl.database.PrimaryKey in project InformationSystem by ObeoNetwork.
the class PrimaryKeyChangeBuilder method handleAlterChange.
@Override
protected Diff handleAlterChange(Match change) {
PrimaryKey oldPk = (PrimaryKey) change.getRight();
PrimaryKey newPk = (PrimaryKey) change.getLeft();
return createUpdatePrimaryKey(oldPk, newPk, change);
}
use of org.obeonetwork.dsl.database.PrimaryKey in project InformationSystem by ObeoNetwork.
the class PrimaryKeyChangeImpl method setPrimaryKey.
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
public void setPrimaryKey(PrimaryKey newPrimaryKey) {
PrimaryKey oldPrimaryKey = primaryKey;
primaryKey = newPrimaryKey;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, DbevolutionPackage.PRIMARY_KEY_CHANGE__PRIMARY_KEY, oldPrimaryKey, primaryKey));
}
use of org.obeonetwork.dsl.database.PrimaryKey in project InformationSystem by ObeoNetwork.
the class UpdatePrimaryKeyImpl method setNewPrimaryKey.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setNewPrimaryKey(PrimaryKey newNewPrimaryKey) {
PrimaryKey oldNewPrimaryKey = newPrimaryKey;
newPrimaryKey = newNewPrimaryKey;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, DbevolutionPackage.UPDATE_PRIMARY_KEY__NEW_PRIMARY_KEY, oldNewPrimaryKey, newPrimaryKey));
}
use of org.obeonetwork.dsl.database.PrimaryKey in project InformationSystem by ObeoNetwork.
the class TableServices method primaryKeyName.
/**
* Returns the name of the specified table's primary key. Returns "" if there's no primary key.
*
* @param table
* @return the table's primary key name.
*/
public String primaryKeyName(Table table) {
PrimaryKey key = table.getPrimaryKey();
String result = null;
if (key != null) {
result = key.getName();
}
return result == null ? "" : result;
}
use of org.obeonetwork.dsl.database.PrimaryKey in project InformationSystem by ObeoNetwork.
the class MpdToMldBidiRules method createPK.
private void createPK(PrimaryKey sourcePk, Table targetTable) {
PrimaryKey targetPk = getFromInputTraceabilityMap(sourcePk, DatabasePackage.Literals.PRIMARY_KEY);
if (targetPk != null && EcoreUtil.equals(targetPk.getOwner(), targetTable)) {
// Reuse existing PK
} else {
// Create a new PK
targetPk = DatabaseFactory.eINSTANCE.createPrimaryKey();
targetTable.setPrimaryKey(targetPk);
}
addToOutputTraceability(sourcePk, targetPk);
targetPk.setName(sourcePk.getName());
targetPk.setComments(sourcePk.getComments());
for (Column sourcePkColumn : sourcePk.getColumns()) {
Column targetPkColumn = getFromOutputTraceabilityMap(sourcePkColumn, DatabasePackage.Literals.COLUMN);
if (!targetPk.getColumns().contains(targetPkColumn)) {
targetPk.getColumns().add(targetPkColumn);
}
if (isTargetMysqlMPD()) {
targetPkColumn.setAutoincrement(true);
}
}
}
Aggregations