public void generate() throws SQLException, NamingException {
    final GraphvizDiagramGenerator gdg = getGraphvizDiagramGenerator();
    final GraphvizSchemaDiagramGeneratorFilter filter = getSchemaDiagramFilter();

    final Set referenceColumnsInIncludedTables = new HashSet();

    final Tables tables = schema.getTables();
    for (int i = 0; i < tables.size(); i++) {
      final Table table = tables.get(i);
      if (filter.includeTableInDiagram(this, table)) {
        final Columns foreignKeyColumns = table.getForeignKeyColumns();
        for (int j = 0; j < foreignKeyColumns.size(); j++)
          referenceColumnsInIncludedTables.add(foreignKeyColumns.get(j));

        final GraphvizSchemaDiagramTableNodeGenerator nodeGenerator =
            filter.getTableNodeGenerator(this, table);
        final GraphvizDiagramNode node = nodeGenerator.generateTableNode(this, filter, table);
        gdg.addNode(node);
      }
    }

    for (Iterator i = referenceColumnsInIncludedTables.iterator(); i.hasNext(); ) {
      final Column foreignKeyColumn = (Column) i.next();
      final ForeignKey foreignKey = foreignKeyColumn.getForeignKey();
      final Column firstSourceColumn = foreignKey.getSourceColumns().getFirst();
      final Column firstReferenceColumn = foreignKey.getReference().getColumns().getFirst();
      final GraphvizSchemaDiagramTableNodeGenerator sourceTableNodeGenerator =
          filter.getTableNodeGenerator(this, firstSourceColumn.getTable());
      final GraphvizSchemaDiagramTableNodeGenerator refTableNodeGenerator =
          filter.getTableNodeGenerator(this, firstReferenceColumn.getTable());

      // make sure both sides have a table.column visible otherwise we won't draw an edge
      if (filter.includeTableInDiagram(this, firstSourceColumn.getTable())
          && filter.includeTableInDiagram(this, firstReferenceColumn.getTable())
          && filter.includeColumnInDiagram(this, firstSourceColumn)
          && filter.includeColumnInDiagram(this, firstReferenceColumn)
          && filter.includeForeignKeyEdgeInDiagram(this, foreignKey)) {
        GraphvizDiagramEdge edge =
            new GraphvizDiagramEdge(
                gdg,
                sourceTableNodeGenerator.getEdgeSourceElementAndPort(this, foreignKey),
                refTableNodeGenerator.getEdgeDestElementAndPort(this, foreignKey));
        filter.formatForeignKeyEdge(this, foreignKey, edge);
        gdg.addEdge(edge);
      }
    }
  }
Ejemplo n.º 2
0
 public PersonIdentifierTable(Table table) {
   this.table = (com.netspective.axiom.schema.table.BasicTable) table;
   this.schema = table.getSchema();
   this.accessors = table.getQueryDefinition().getSelects();
   crSessIdForeignKey = table.getColumns().get(COLINDEX_CR_SESS_ID).getForeignKey();
   recStatIdForeignKey = table.getColumns().get(COLINDEX_REC_STAT_ID).getForeignKey();
   personIdForeignKey =
       (ParentForeignKey) table.getColumns().get(COLINDEX_PERSON_ID).getForeignKey();
   orgIdForeignKey = table.getColumns().get(COLINDEX_ORG_ID).getForeignKey();
   idTypeIdForeignKey = table.getColumns().get(COLINDEX_ID_TYPE_ID).getForeignKey();
   sourceTypeIdForeignKey = table.getColumns().get(COLINDEX_SOURCE_TYPE_ID).getForeignKey();
 }
Ejemplo n.º 3
0
 public PersonEthnicityTable(Table table) {
   this.table = (com.netspective.axiom.schema.table.BasicTable) table;
   this.schema = table.getSchema();
   this.accessors = table.getQueryDefinition().getSelects();
   crSessIdForeignKey = table.getColumns().get(COLINDEX_CR_SESS_ID).getForeignKey();
   recStatIdForeignKey = table.getColumns().get(COLINDEX_REC_STAT_ID).getForeignKey();
   personIdForeignKey =
       (ParentForeignKey) table.getColumns().get(COLINDEX_PERSON_ID).getForeignKey();
   ethnicityIdForeignKey = table.getColumns().get(COLINDEX_ETHNICITY_ID).getForeignKey();
 }