Search in sources :

Example 41 with Table

use of org.obeonetwork.dsl.database.Table in project InformationSystem by ObeoNetwork.

the class ColumnSpec method addToPrimaryKey.

@Override
public void addToPrimaryKey() {
    // Do nothing if the column is already a PK column or if it does not belong to a table
    if (isInPrimaryKey() == false && getOwner() != null && getOwner() instanceof Table) {
        Table table = (Table) getOwner();
        // First, ensure there is a Primary Key defined on this table
        PrimaryKey pk = table.getPrimaryKey();
        if (pk == null) {
            // Create a new PK
            pk = DatabaseFactory.eINSTANCE.createPrimaryKey();
            pk.setName(table.getName() + "_PK");
            table.setPrimaryKey(pk);
        }
        // Then attach the column to the primary key
        pk.getColumns().add(this);
    }
}
Also used : Table(org.obeonetwork.dsl.database.Table) PrimaryKey(org.obeonetwork.dsl.database.PrimaryKey)

Example 42 with Table

use of org.obeonetwork.dsl.database.Table in project InformationSystem by ObeoNetwork.

the class RenameTableChangeImpl method setNewTable.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public void setNewTable(Table newNewTable) {
    Table oldNewTable = newTable;
    newTable = newNewTable;
    if (eNotificationRequired())
        eNotify(new ENotificationImpl(this, Notification.SET, DbevolutionPackage.RENAME_TABLE_CHANGE__NEW_TABLE, oldNewTable, newTable));
}
Also used : Table(org.obeonetwork.dsl.database.Table) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Example 43 with Table

use of org.obeonetwork.dsl.database.Table in project InformationSystem by ObeoNetwork.

the class UpdateTableCommentChangeImpl method setNewTable.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public void setNewTable(Table newNewTable) {
    Table oldNewTable = newTable;
    newTable = newNewTable;
    if (eNotificationRequired())
        eNotify(new ENotificationImpl(this, Notification.SET, DbevolutionPackage.UPDATE_TABLE_COMMENT_CHANGE__NEW_TABLE, oldNewTable, newTable));
}
Also used : Table(org.obeonetwork.dsl.database.Table) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Example 44 with Table

use of org.obeonetwork.dsl.database.Table in project InformationSystem by ObeoNetwork.

the class ColumnServicesTest method isMandatoryNullTest.

@Test
public void isMandatoryNullTest() {
    Table table = getGSSerieTable();
    Column col = getColumn(table, "No table");
    assertEquals("No", new ColumnServices().isMandatory(col));
}
Also used : Table(org.obeonetwork.dsl.database.Table) Column(org.obeonetwork.dsl.database.Column) Test(org.junit.Test) AbstractTest(org.obeonetwork.database.m2doc.services.common.AbstractTest)

Example 45 with Table

use of org.obeonetwork.dsl.database.Table in project InformationSystem by ObeoNetwork.

the class ColumnServicesTest method checkForeignKeyNullTest.

@Test
public void checkForeignKeyNullTest() {
    Table table = getGSSerieTable();
    Column col = getColumn(table, "No table");
    assertEquals("", new ColumnServices().checkInForeignKey(col));
}
Also used : Table(org.obeonetwork.dsl.database.Table) Column(org.obeonetwork.dsl.database.Column) Test(org.junit.Test) AbstractTest(org.obeonetwork.database.m2doc.services.common.AbstractTest)

Aggregations

Table (org.obeonetwork.dsl.database.Table)86 Column (org.obeonetwork.dsl.database.Column)41 Test (org.junit.Test)31 AbstractTest (org.obeonetwork.database.m2doc.services.common.AbstractTest)31 AbstractTable (org.obeonetwork.dsl.database.AbstractTable)22 EObject (org.eclipse.emf.ecore.EObject)17 ForeignKey (org.obeonetwork.dsl.database.ForeignKey)16 ArrayList (java.util.ArrayList)11 ForeignKeyElement (org.obeonetwork.dsl.database.ForeignKeyElement)7 Index (org.obeonetwork.dsl.database.Index)7 ResultSet (java.sql.ResultSet)6 SQLException (java.sql.SQLException)6 ReferencesTableSettings (org.eclipse.emf.eef.runtime.ui.widgets.referencestable.ReferencesTableSettings)6 Viewer (org.eclipse.jface.viewers.Viewer)6 ViewerFilter (org.eclipse.jface.viewers.ViewerFilter)6 Constraint (org.obeonetwork.dsl.database.Constraint)6 Sequence (org.obeonetwork.dsl.database.Sequence)6 BigInteger (java.math.BigInteger)5 PreparedStatement (java.sql.PreparedStatement)5 EObjectPropertiesEditionContext (org.eclipse.emf.eef.runtime.context.impl.EObjectPropertiesEditionContext)5