Search in sources :

Example 6 with PrimaryKey

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);
}
Also used : RemovePrimaryKey(org.obeonetwork.dsl.database.dbevolution.RemovePrimaryKey) UpdatePrimaryKey(org.obeonetwork.dsl.database.dbevolution.UpdatePrimaryKey) PrimaryKey(org.obeonetwork.dsl.database.PrimaryKey) AddPrimaryKey(org.obeonetwork.dsl.database.dbevolution.AddPrimaryKey)

Example 7 with PrimaryKey

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));
}
Also used : ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl) PrimaryKey(org.obeonetwork.dsl.database.PrimaryKey)

Example 8 with 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));
}
Also used : ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl) UpdatePrimaryKey(org.obeonetwork.dsl.database.dbevolution.UpdatePrimaryKey) PrimaryKey(org.obeonetwork.dsl.database.PrimaryKey)

Example 9 with PrimaryKey

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;
}
Also used : PrimaryKey(org.obeonetwork.dsl.database.PrimaryKey)

Example 10 with PrimaryKey

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);
        }
    }
}
Also used : Column(org.obeonetwork.dsl.database.Column) PrimaryKey(org.obeonetwork.dsl.database.PrimaryKey)

Aggregations

PrimaryKey (org.obeonetwork.dsl.database.PrimaryKey)15 Table (org.obeonetwork.dsl.database.Table)3 UpdatePrimaryKey (org.obeonetwork.dsl.database.dbevolution.UpdatePrimaryKey)3 ArrayList (java.util.ArrayList)2 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)2 Column (org.obeonetwork.dsl.database.Column)2 AddPrimaryKey (org.obeonetwork.dsl.database.dbevolution.AddPrimaryKey)2 RemovePrimaryKey (org.obeonetwork.dsl.database.dbevolution.RemovePrimaryKey)2 BigInteger (java.math.BigInteger)1 ResultSet (java.sql.ResultSet)1 SQLException (java.sql.SQLException)1 EObject (org.eclipse.emf.ecore.EObject)1 EObjectStrictFilter (org.eclipse.emf.eef.runtime.impl.filters.EObjectStrictFilter)1 ReferencesTableSettings (org.eclipse.emf.eef.runtime.ui.widgets.referencestable.ReferencesTableSettings)1 Viewer (org.eclipse.jface.viewers.Viewer)1 ViewerFilter (org.eclipse.jface.viewers.ViewerFilter)1 AbstractTable (org.obeonetwork.dsl.database.AbstractTable)1 DataBase (org.obeonetwork.dsl.database.DataBase)1 Schema (org.obeonetwork.dsl.database.Schema)1 Sequence (org.obeonetwork.dsl.database.Sequence)1