Package net.sf.minuteProject.configuration.bean

Examples of net.sf.minuteProject.configuration.bean.Reference


  public static List<Reference> getParents (Database database, Table table) {
    //return getParents(table);
    // Duplicated code
    List<Reference> list = new ArrayList<Reference>();
    net.sf.minuteProject.configuration.bean.model.data.Reference ref;
    Reference reference;
    ForeignKey [] foreignKeys = table.getForeignKeys();
    //logger.info("table = "+table.getName()+", count FK = "+foreignKeys.length);
    for (int i = 0; i < foreignKeys.length; i++) {
      ref = foreignKeys[i].getFirstReference();
      String tablename = foreignKeys[i].getForeignTableName();
      Table table2 = TableUtils.getTable(database,tablename);
      String columnName = null;
      if (ref!=null)
        columnName = ref.getForeignColumnName();
      Column column2 = ColumnUtils.getColumn (table2, columnName);
      //reference = new Reference(table2, ColumnUtils.getColumn(table2, ref.getLocalColumnName()), tablename, ref.getLocalColumnName());
      reference = new Reference(table2, column2, tablename, columnName);
      reference.setLocalColumn(ref.getLocalColumn());
     
      //logger.info("table = "+tablename+", columnName = "+columnName);
      addReference(list, reference);       
    }
    return list;
View Full Code Here


 
  public static List getChildren (Database database, Table table) {
    List list = new ArrayList();
    String columnRef;
    net.sf.minuteProject.configuration.bean.model.data.Reference ref;
    Reference reference;
    //Table [] tables = database.getTables();
    //replaced with entities to find enriched FK in the views
    Table [] tables = database.getEntities();
      for (int i = 0; i < tables.length; i++) {
        ForeignKey [] fk = tables[i].getForeignKeys();
          for (int j = 0; j < fk.length; j++) {
            String tableName = fk[j].getForeignTableName();
            if (tableName!=null && fk[j].isBidirectional()) {
              if (tableName.equals(table.getName())) {
                columnRef = new String();
                ref = fk[j].getReference(0);
                columnRef = ref.getLocalColumnName();
//                if (columnRef==null)
//                  logger.info("- no localcolumnName for tab");
                Column column2 = ColumnUtils.getColumn (tables[i], ref.getLocalColumnName());
                reference = new Reference(tables[i], column2, tables[i].getName(), ref.getLocalColumnName());
                reference.setLocalColumnName(ref.getLocalColumnName());
                reference.setForeignColumnName(ref.getForeignColumnName());
                addReference(list, reference);
              }
            }
          }     
        }   
View Full Code Here

    }
    return null;   
  }
 
  public Reference getReference(Table table, Column column) {
    Reference reference = new Reference();
    reference.setTableName(table.getName());
    reference.setColumnName(column.getName());
    reference.setTable(table);
    reference.setColumn(column);
    return reference;
  }
View Full Code Here

    reference.setColumn(column);
    return reference;
  }
 
  public Reference getReference(Table table, Column column, String tableName, String columnName) {
    Reference reference = new Reference();
    reference.setTableName(tableName);
    reference.setColumnName(columnName);
    reference.setTable(table);
    reference.setColumn(column);
    return reference;
 
View Full Code Here

TOP

Related Classes of net.sf.minuteProject.configuration.bean.Reference

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.