private Object isPartOfUniqueConstraintKey(EColumn owner) { for (EReferenceConstraint refConstraint : owner.getReferencingConstraints()) if (refConstraint instanceof EUniqueConstraint) return true; return false; }
private boolean isPrimaryKey(EColumn owner) { for (EReferenceConstraint refConstraint : owner.getReferencingConstraints()) if (refConstraint instanceof EPrimaryKey) return true; return false; }
private boolean isPartOfForeingKey(EColumn owner) { for (EReferenceConstraint refConstraint : owner.getReferencingConstraints()) if (refConstraint instanceof EForeignKey) return true; return false; }
private void setPrimaryKey(EColumn owner, boolean newValue) { boolean oldValue = isPrimaryKey(owner); if (oldValue == newValue) return; EBaseTable baseTable = (EBaseTable) owner.getTable(); EPrimaryKey pk = baseTable.getPrimaryKey(); if (newValue) { if (pk == null) { pk = EConstraintsFactory.eINSTANCE.createPrimaryKey(); baseTable.getConstraints().add(pk); } if (!pk.getMembers().contains(owner)) pk.getMembers().add(owner); } else if (pk != null) { if (pk.getMembers().contains(owner)) pk.getMembers().remove(owner); } }
private ETable getTable(EColumn column) { return (ETable) column.eContainer(); }