FileDocCategorySizeDatePackage
TableImpl.javaAPI DocExample4236Tue Dec 08 01:21:00 GMT 1998oisoft.togetherx.scripts.SQL.impl

TableImpl

public class TableImpl extends Object implements SQLTable

Fields Summary
private SQLModelImpl
myModel
private oisoft.togetherx.scriptapi.UML.UMLClass
myClass
private String
myName
private COM.objectspace.jgl.HashMap
myColumns
private COM.objectspace.jgl.HashMap
myForeignColumns
Constructors Summary
TableImpl(oisoft.togetherx.scriptapi.UML.UMLClass clazz, SQLModelImpl model)


     
    myClass = clazz;
    myModel = model;
  
Methods Summary
java.lang.StringcreateColumnName(ColumnImpl column)

    String fullName = null;
    if( column.isForeignKey() ){
      fullName = prefixForeignKey()+column.getAttribute().getName();
    }
    else{
      fullName = column.getAttribute().getName();
    }
    String result = myModel.getNameConstraints().shorten(fullName,
      myModel.getNameConstraints().getMaxColumnNameLength());
    return myModel.dereserve(result);
  
public java.lang.StringgetCatalog()

    return null;
  
SQLColumngetColumn(oisoft.togetherx.scriptapi.UML.UMLAttribute attribute)

    return getColumn(attribute,false);
  
private SQLColumngetColumn(oisoft.togetherx.scriptapi.UML.UMLAttribute attribute, boolean forcePrimaryKey)

    SQLColumn result = (SQLColumn)myColumns.get(attribute);
    if( result == null ){
      boolean nullable = !attribute.hasProperty(tagNamePrimaryKey());
      result = new ColumnImpl(attribute,nullable,forcePrimaryKey,this);
      myColumns.put(attribute,result);
    }
    return result;
  
public java.util.EnumerationgetColumns()

    return getColumns(true);
  
public java.util.EnumerationgetColumns(boolean showForeign)

    return new ColumnEnumeration(this,myModel,showForeign);
  
public java.util.EnumerationgetConstraints()

todo
Implement it!

    return new TableConstraintEnumeration(this);
  
SQLColumngetForeignKeyColumn(ColumnImpl column, boolean forcePrimaryKey)

    //return getColumn(column.getAttribute(),forcePrimaryKey);
    SQLColumn result = (SQLColumn)myForeignColumns.get(column);
    if( result == null ){
      boolean nullable = !column.getAttribute().hasProperty(tagNamePrimaryKey());
      result = new ColumnImpl(column.getAttribute(),nullable,forcePrimaryKey,this,true);
      myForeignColumns.put(column,result);
    }
    return result;
  
java.lang.StringgetForeignKeyName(SQLForeignKey fk)

    String fullName = "CONSTRAINT_FK_"+fk.getReferencedTable().getName();
    String result = myModel.getNameConstraints().shorten(fullName,
      myModel.getNameConstraints().getMaxColumnNameLength());
    return myModel.getUniqueName(result,myModel.getNameConstraints().getMaxColumnNameLength());
  
public SQLModelgetModel()

    return myModel;
  
public java.lang.StringgetName()

    if( myName == null ){
      myName = myModel.createTableName(myClass.toShortString());
    }
    return myName;
  
public java.util.EnumerationgetPrimaryKeyColumns()

    return getPrimaryKeyColumns(true);
  
public java.util.EnumerationgetPrimaryKeyColumns(boolean showForeign)

    return new ColumnEnumeration(this,myModel,showForeign,true);
    //return new FilterEnumeration(getColumns(showForeign),new PrimaryKeyColumnFilter());
  
java.lang.StringgetPrimaryKeyName()

    String fullName = "PK_"+getName();
    String result = myModel.getNameConstraints().shorten(fullName,
      myModel.getNameConstraints().getMaxColumnNameLength());
    return myModel.getUniqueName(result,myModel.getNameConstraints().getMaxColumnNameLength());
  
public java.lang.StringgetRemarks()

todo
Use doc from model for remarks

    return "";
  
public java.lang.StringgetSchema()

    return null;
  
SQLDiagramTagsgetTags()

    return myModel.getTags();
  
public java.lang.StringgetType()

todo
create tag for table type
see
java.sql.DatabaseMetaData#getTables

    return "TABLE";
  
oisoft.togetherx.scriptapi.UML.UMLClassgetUMLClass()

    return myClass;
  
java.lang.StringprefixForeignKey()

    return "FK_";
  
private java.lang.StringtagNamePrimaryKey()

    return getTags().attributePrimaryKey();