public override DB.DatabaseItem createAsNewItem(DB.DatabaseItem owner, bool save = true) { Table newTable = owner as Table; Database existingDatabase = owner as Database; if (newTable == null) { //look for corresponding table in existingDatabase newTable = (Table)existingDatabase.tables.FirstOrDefault(x => x.name == this.ownerTable.name); } if (newTable != null) { var newColumn = new Column(newTable, this.name); newColumn.isNotNullable = isNotNullable; newColumn.type = type; newColumn.logicalAttribute = logicalAttribute; newColumn.logicalElements = logicalElements; newColumn.isOverridden = isOverridden; newColumn.isRenamed = isRenamed; newColumn.position = position; newColumn.initialValue = initialValue; newColumn.derivedFromItem = this; if (save) { newColumn.save(); } return(newColumn); } return(null); }
public override DB.DatabaseItem createAsNewItem(DB.DatabaseItem owner, bool save = true) { Table newTable = owner as Table; Database existingDatabase = owner as Database; if (newTable != null) { existingDatabase = newTable.databaseOwner as Database; } if (newTable == null) { //look for corresponding table in existingDatabase newTable = (Table)existingDatabase.tables.FirstOrDefault(x => x.name == this.ownerTable.name); } var newForeignTable = existingDatabase.tables.FirstOrDefault(x => x.name == this.foreignTable.name); if (newTable != null && newForeignTable != null) { var newForeignKey = new ForeignKey(newTable, this._involvedColumns); newForeignKey.name = name; newForeignKey._foreignTable = (Table)newForeignTable; newForeignKey._logicalAssociation = _logicalAssociation; this.setLogicalName(save); newForeignKey.isOverridden = isOverridden; newForeignKey.derivedFromItem = this; //set default value for onDelete newForeignKey.onDelete = "Restrict"; if (save) { newForeignKey.save(); } return(newForeignKey); } return(null); }
public DB.DatabaseItem createAsNewItem(DB.DatabaseItem owner, bool save = true) { //create as new var newItem = createAsNew((DatabaseItem)owner, save); //return return(newItem); }
public DatabaseItemComparison addOwnedComparison(DB.DatabaseItem existingItem, DB.DatabaseItem newItem) { var newComparison = new EADatabaseItemComparison(existingItem, newItem); this.ownedComparisons.Add(newComparison); newComparison.ownerComparison = this; return(newComparison); }
protected override void updateDetails(DB.DatabaseItem newDatabaseItem) { var newColumn = (Column)newDatabaseItem; this._isNotNullable = newColumn.isNotNullable; this._logicalAttribute = newColumn.logicalAttribute; this._type = newColumn._type; this.isOverridden = newColumn.isOverridden; }
public EADatabaseItemComparison(DB.DatabaseItem newDatabaseItem, DB.DatabaseItem existingDatabaseItem) { this._newDatabaseItem = newDatabaseItem; this._existingDatabaseItem = existingDatabaseItem; //determine if this item was renamed determineRenamed(); //compare the new against the existing item this.compare(); }
public void renameItem(DB.DatabaseItem item, string newName) { //get corresponding transformer var transformer = getCorrespondingTransformer(item); if (transformer != null) { transformer.rename(newName); } }
protected override void updateDetails(DB.DatabaseItem newDatabaseItem) { base.updateDetails(newDatabaseItem); ForeignKey newForeignKey = (ForeignKey)newDatabaseItem; //update the association this._foreignTable = newForeignKey._foreignTable; //set logical association this.logicalAssociation = newForeignKey.logicalAssociation; }
private void addDatabaseItemSpecifics(ListViewItem listViewItem, DB.DatabaseItem databaseItem, string newName) { listViewItem.SubItems.Add(newName); if (databaseItem != null) { listViewItem.SubItems.Add(databaseItem.properties); } else { listViewItem.SubItems.Add(string.Empty); } }
protected override void updateDetails(DB.DatabaseItem newDatabaseItem) { var newColumn = (Column)newDatabaseItem; this._isNotNullable = newColumn.isNotNullable; this._logicalAttribute = newColumn.logicalAttribute; this._type = newColumn._type; this.isOverridden = newColumn.isOverridden; this.isRenamed = newColumn.isRenamed; this.position = newColumn.position; this.initialValue = newColumn.initialValue; }
private string getLogicalName(DB.DatabaseItem databaseItem) { string logicalName = string.Empty; if (databaseItem.logicalElements != null) { var logicalElement = databaseItem.logicalElements.FirstOrDefault(); if (logicalElement != null) { logicalName = logicalElement.name; } } return(logicalName); }
public override DB.DatabaseItem createAsNewItem(DB.DatabaseItem owner, bool save = true) { Database existingDatabase = owner as Database; var newTable = new Table((Database)existingDatabase, this.name); newTable.logicalElements = this.logicalElements; newTable.derivedFromItem = this; newTable.tableSpace = this.tableSpace; if (save) { newTable.save(); } return(newTable); }
protected override void updateDetails(DB.DatabaseItem newDatabaseItem) { base.updateDetails(newDatabaseItem); ForeignKey newForeignKey = (ForeignKey)newDatabaseItem; //update the association var newForeignTable = this.ownerTable.databaseOwner.tables.FirstOrDefault(x => x.name == newForeignKey._foreignTable.name); if (newForeignTable != null) { this._foreignTable = (Table)newForeignTable; } //set logical association this.logicalAssociation = newForeignKey.logicalAssociation; }
public DB.DatabaseItem createAsNewItem(DB.DatabaseItem owner, string newName, bool save = true) { //temporarily rename this item to the new name string originalName = this.name; this.name = newName; //create the new items var newItem = this.createAsNewItem(owner, save); //rename back to original this.name = originalName; //return the new item return(newItem); }
public void update(DB.DatabaseItem newDatabaseItem, bool save = true) { //check if types are the same if (newDatabaseItem.itemType != this.itemType) { throw new Exception(string.Format("Cannot update object of type {0} with object of type {1}", this.itemType, newDatabaseItem.itemType)); } this.name = newDatabaseItem.name; this.isOverridden = newDatabaseItem.isOverridden; this.updateDetails(newDatabaseItem); if (save) { this.save(); } }
public override DB.DatabaseItem createAsNewItem(DB.DatabaseItem owner, bool save = true) { Table newTable = owner as Table; Database existingDatabase = owner as Database; if (newTable == null) { //look for corresponding table in existingDatabase newTable = (Table)existingDatabase.tables.FirstOrDefault(x => x.name == this.ownerTable.name); } if (newTable != null) { var index = new Index(newTable, this._involvedColumns); index.name = name; if (save) { index.save(); } return(index); } return(null); }
public override DB.DatabaseItem createAsNewItem(DB.DatabaseItem owner, bool save = true) { Table newTable = owner as Table; Database existingDatabase = owner as Database; if (newTable == null) { //look for corresponding table in existingDatabase newTable = (Table)existingDatabase.tables.FirstOrDefault(x => x.name == this.ownerTable.name); } if (newTable != null && newTable.primaryKey == null) //only create it if htere is not already one { var newPrimaryKey = new PrimaryKey(newTable, this._involvedColumns); newPrimaryKey.name = name; //newPrimaryKey.isOverridden = this.isOverridden; newPrimaryKey.derivedFromItem = this; if (save) { newPrimaryKey.save(); } return(newPrimaryKey); } return(null); }
void CompareDBListViewMouseDoubleClick(object sender, MouseEventArgs e) { ListViewHitTestInfo info = ((ListView)sender).HitTest(e.X, e.Y); if (info.Item != null) { var comparedItem = (DB.Compare.DatabaseItemComparison)info.Item.Tag; if (info.SubItem != null) { int columnIndex = info.Item.SubItems.IndexOf(info.SubItem); DB.DatabaseItem clickedItem = null; if (columnIndex <= 5) { clickedItem = comparedItem.newDatabaseItem; selectLogicalItem(clickedItem, null); } else { clickedItem = comparedItem.existingDatabaseItem; selectDatabaseItem(clickedItem, null); } } } }
public void update(DB.DatabaseItem newDatabaseItem, bool save = true) { //don't think we ever need this one throw new NotImplementedException(); }
public override DB.Transformation.DatabaseItemTransformer getCorrespondingTransformer(DB.DatabaseItem item) { if (item == this.foreignKey) { return(this); } return(null); }
protected override void updateDetails(DB.DatabaseItem newDatabaseItem) { var newConstraint = (Constraint)newDatabaseItem; this.involvedColumns = newConstraint.involvedColumns; }
protected override void updateDetails(DB.DatabaseItem newDatabaseItem) { //nothing extra to do here }
public override DB.DatabaseItem createAsNewItem(DB.DatabaseItem owner, bool save = true) { //TODO: figure out how to handle creation of new databases return(null); }
public abstract DB.DatabaseItem createAsNewItem(DB.DatabaseItem owner, bool save = true);
protected abstract void updateDetails(DB.DatabaseItem newDatabaseItem);
public DB.DatabaseItem createAsNewItem(DB.DatabaseItem owner, string newName, bool save = true) { throw new NotImplementedException(); }
public override DB.Transformation.DatabaseItemTransformer getCorrespondingTransformer(DB.DatabaseItem item) { //check if the item is our new database if (item == this.newDatabase) { return(this); } //go deeper DB.Transformation.DatabaseItemTransformer correspondingTransformer = null; foreach (var tableTransformer in this.tableTransformers) { correspondingTransformer = tableTransformer.getCorrespondingTransformer(item); if (correspondingTransformer != null) { break; } } return(correspondingTransformer); }
public EADatabaseItemComparison(DB.DatabaseItem newDatabaseItem, DB.DatabaseItem existingDatabaseItem) { this.newDatabaseItem = newDatabaseItem; this.existingDatabaseItem = existingDatabaseItem; }
public DB.DatabaseItem createAsNewItem(DB.DatabaseItem owner, bool save = true) { //do nothing. deleting or adding of base datatypes should happen manually in the EA GUI return(null); }
public override DB.Transformation.DatabaseItemTransformer getCorrespondingTransformer(DB.DatabaseItem item) { //check if the item is our table if (item == this.table) { return(this); } //check columntransformers DB.Transformation.DatabaseItemTransformer correspondingTransformer = null; foreach (var columnTransformer in this.columnTransformers) { correspondingTransformer = columnTransformer.getCorrespondingTransformer(item); if (correspondingTransformer != null) { return(correspondingTransformer); } } //check foreignKey transformers foreach (var foreignKeyTransformer in this.foreignKeyTransformers) { correspondingTransformer = foreignKeyTransformer.getCorrespondingTransformer(item); if (correspondingTransformer != null) { return(correspondingTransformer); } } //check primary key transformer if (this.primaryKeyTransformer != null) { return(primaryKeyTransformer.getCorrespondingTransformer(item)); } //not found return(correspondingTransformer); }