Package net.sf.minuteProject.configuration.bean.model.data.impl.DDLUtils

Examples of net.sf.minuteProject.configuration.bean.model.data.impl.DDLUtils.ReferenceDDLUtils


  }
 
  public static net.sf.minuteProject.configuration.bean.model.data.Reference getReference(Field field, Database database) {
    org.apache.ddlutils.model.Reference referenceDDLUtils = new org.apache.ddlutils.model.Reference();
//    referenceDDLUtils.setForeignColumn(foreignColu)
    net.sf.minuteProject.configuration.bean.model.data.Reference reference = new ReferenceDDLUtils(referenceDDLUtils);
    String tableName = field.getEntity().getName();
    String columnName = field.getName();
    String foreignTableName = field.getLinkToTargetEntity();

//    Database database = field.getEntity().getEnrichment().getBusinessModel().getModel().getDataModel().getDatabase();
   
    // is it a view ?
    Table table= TableUtils.getTable(database, tableName);
    if (table==null)
      table = TableUtils.getView(database, tableName);
     
    Column column = ColumnUtils.getColumn(table, columnName);
   
    // is it a view
    Table foreignTable= TableUtils.getTable(database, foreignTableName);
    if (foreignTable==null)
      foreignTable = TableUtils.getView(database, foreignTableName);
     
    String foreignColumnName = field.getLinkToTargetField();
    if (foreignColumnName==null)
      foreignColumnName = TableUtils.getPrimaryKey(foreignTable);
    Column foreignColumn = ColumnUtils.getColumn(foreignTable, foreignColumnName);
   
    if (table!=null && column != null && foreignTable!=null && foreignColumn!=null) {
      reference.setLocalTable(table);
      reference.setLocalColumn(column);
      reference.getLocalColumn().setAlias(reference.getLocalColumn().getAlias());
      reference.setForeignTable(foreignTable);
      reference.setForeignColumn(foreignColumn);
      reference.getForeignColumn().setAlias(reference.getForeignColumn().getAlias());
     
      reference.setLocalColumnName(columnName);
      reference.setLocalTableName(tableName);
      reference.setForeignColumnName(foreignColumnName);
      reference.setForeignTableName(foreignTableName);
      return reference;
    }
    return null;
   
  }
View Full Code Here

TOP

Related Classes of net.sf.minuteProject.configuration.bean.model.data.impl.DDLUtils.ReferenceDDLUtils

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.