Search in sources :

Example 11 with IncludeTable

use of org.apache.cayenne.dbsync.reverse.dbimport.IncludeTable in project cayenne by apache.

the class IncludeTableHandler method createIncludeTable.

private void createIncludeTable() {
    includeTable = new IncludeTable();
    entity.addIncludeTable(includeTable);
}
Also used : IncludeTable(org.apache.cayenne.dbsync.reverse.dbimport.IncludeTable)

Example 12 with IncludeTable

use of org.apache.cayenne.dbsync.reverse.dbimport.IncludeTable in project cayenne by apache.

the class SchemaHandler method createIncludeTable.

private void createIncludeTable(String includeTableData) {
    if (includeTableData.trim().length() == 0) {
        return;
    }
    if (schema != null) {
        IncludeTable includeTable = new IncludeTable();
        includeTable.setName(includeTableData);
        schema.addIncludeTable(includeTable);
    }
}
Also used : IncludeTable(org.apache.cayenne.dbsync.reverse.dbimport.IncludeTable)

Example 13 with IncludeTable

use of org.apache.cayenne.dbsync.reverse.dbimport.IncludeTable in project cayenne by apache.

the class LoadDbSchemaAction method performAction.

public void performAction(ActionEvent e, TreePath tablePath) {
    final DbImportView rootParent = ((DbImportView) draggableTreePanel.getParent().getParent());
    rootParent.getLoadDbSchemaProgress().setVisible(true);
    rootParent.getLoadDbSchemaButton().setEnabled(false);
    Thread thread = new Thread(() -> {
        LoadDbSchemaAction.this.setEnabled(false);
        rootParent.lockToolbarButtons();
        draggableTreePanel.getMoveButton().setEnabled(false);
        draggableTreePanel.getMoveInvertButton().setEnabled(false);
        try {
            DBConnectionInfo connectionInfo = getConnectionInfo("Load Db Schema");
            if (connectionInfo == null) {
                return;
            }
            if (tablePath != null) {
                Object userObject = ((DbImportTreeNode) tablePath.getLastPathComponent()).getUserObject();
                if (userObject instanceof Catalog) {
                    Catalog catalog = (Catalog) userObject;
                    if (catalog.getSchemas().isEmpty()) {
                        loadTables(connectionInfo, tablePath, rootParent);
                    }
                } else if (userObject instanceof Schema) {
                    loadTables(connectionInfo, tablePath, rootParent);
                } else if (userObject instanceof IncludeTable) {
                    loadColumns(connectionInfo, tablePath);
                } else {
                    loadTables(connectionInfo, tablePath, rootParent);
                }
            } else {
                loadDataBase(connectionInfo);
            }
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(Application.getFrame(), ex.getMessage(), "Error loading db schema", JOptionPane.ERROR_MESSAGE);
            LOGGER.warn("Error loading db schema", ex);
        } finally {
            rootParent.getLoadDbSchemaButton().setEnabled(true);
            rootParent.getLoadDbSchemaProgress().setVisible(false);
            rootParent.unlockToolbarButtons();
        }
    });
    thread.start();
}
Also used : DbImportView(org.apache.cayenne.modeler.editor.dbimport.DbImportView) DbImportTreeNode(org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode) Schema(org.apache.cayenne.dbsync.reverse.dbimport.Schema) IncludeTable(org.apache.cayenne.dbsync.reverse.dbimport.IncludeTable) DBConnectionInfo(org.apache.cayenne.modeler.pref.DBConnectionInfo) Catalog(org.apache.cayenne.dbsync.reverse.dbimport.Catalog) SQLException(java.sql.SQLException)

Example 14 with IncludeTable

use of org.apache.cayenne.dbsync.reverse.dbimport.IncludeTable in project cayenne by apache.

the class DbImporterMojoTest method testFilteringConfig.

@Test
public void testFilteringConfig() throws Exception {
    DbImporterMojo cdbImport = getCdbImport("config/pom-01.xml");
    assertEquals(2, cdbImport.getReverseEngineering().getCatalogs().size());
    Iterator<Catalog> iterator = cdbImport.getReverseEngineering().getCatalogs().iterator();
    assertEquals("catalog-name-01", iterator.next().getName());
    Catalog catalog = iterator.next();
    assertEquals("catalog-name-02", catalog.getName());
    Iterator<Schema> schemaIterator = catalog.getSchemas().iterator();
    assertEquals("schema-name-01", schemaIterator.next().getName());
    Schema schema = schemaIterator.next();
    assertEquals("schema-name-02", schema.getName());
    Iterator<IncludeTable> includeTableIterator = schema.getIncludeTables().iterator();
    assertEquals("incTable-01", includeTableIterator.next().getPattern());
    IncludeTable includeTable = includeTableIterator.next();
    assertEquals("incTable-02", includeTable.getPattern());
    assertEquals("includeColumn-01", includeTable.getIncludeColumns().iterator().next().getPattern());
    assertEquals("excludeColumn-01", includeTable.getExcludeColumns().iterator().next().getPattern());
    assertEquals("includeColumn-02", schema.getIncludeColumns().iterator().next().getPattern());
    assertEquals("excludeColumn-02", schema.getExcludeColumns().iterator().next().getPattern());
    assertEquals("includeColumn-03", catalog.getIncludeColumns().iterator().next().getPattern());
    assertEquals("excludeColumn-03", catalog.getExcludeColumns().iterator().next().getPattern());
    schemaIterator = cdbImport.getReverseEngineering().getSchemas().iterator();
    schema = schemaIterator.next();
    assertEquals("schema-name-03", schema.getName());
    schema = schemaIterator.next();
    assertEquals("schema-name-04", schema.getName());
    includeTableIterator = schema.getIncludeTables().iterator();
    assertEquals("incTable-04", includeTableIterator.next().getPattern());
    assertEquals("excTable-04", schema.getExcludeTables().iterator().next().getPattern());
    includeTable = includeTableIterator.next();
    assertEquals("incTable-05", includeTable.getPattern());
    assertEquals("includeColumn-04", includeTable.getIncludeColumns().iterator().next().getPattern());
    assertEquals("excludeColumn-04", includeTable.getExcludeColumns().iterator().next().getPattern());
    assertEquals("includeColumn-04", schema.getIncludeColumns().iterator().next().getPattern());
    assertEquals("excludeColumn-04", schema.getExcludeColumns().iterator().next().getPattern());
    assertEquals("includeColumn-03", catalog.getIncludeColumns().iterator().next().getPattern());
    assertEquals("excludeColumn-03", catalog.getExcludeColumns().iterator().next().getPattern());
}
Also used : Schema(org.apache.cayenne.dbsync.reverse.dbimport.Schema) IncludeTable(org.apache.cayenne.dbsync.reverse.dbimport.IncludeTable) Catalog(org.apache.cayenne.dbsync.reverse.dbimport.Catalog) Test(org.junit.Test)

Example 15 with IncludeTable

use of org.apache.cayenne.dbsync.reverse.dbimport.IncludeTable in project cayenne by apache.

the class FiltersConfigBuilderTest method testCompact_01.

@Test
public void testCompact_01() {
    ReverseEngineering engineering = new ReverseEngineering();
    engineering.addIncludeTable(new IncludeTable("table1"));
    engineering.addIncludeTable(new IncludeTable("table2"));
    engineering.addIncludeTable(new IncludeTable("table3"));
    engineering.addIncludeColumn(new IncludeColumn("includeColumn"));
    FiltersConfigBuilder builder = new FiltersConfigBuilder(engineering);
    builder.compact();
    assertEquals("ReverseEngineering: \n" + "  Catalog: null\n" + "    Schema: null\n" + "      IncludeTable: table1\n" + "        IncludeColumn: includeColumn\n" + "      IncludeTable: table2\n" + "        IncludeColumn: includeColumn\n" + "      IncludeTable: table3\n" + "        IncludeColumn: includeColumn\n\n" + "  Use primitives", engineering.toString());
}
Also used : ReverseEngineering(org.apache.cayenne.dbsync.reverse.dbimport.ReverseEngineering) IncludeTable(org.apache.cayenne.dbsync.reverse.dbimport.IncludeTable) IncludeColumn(org.apache.cayenne.dbsync.reverse.dbimport.IncludeColumn) Test(org.junit.Test)

Aggregations

IncludeTable (org.apache.cayenne.dbsync.reverse.dbimport.IncludeTable)26 Catalog (org.apache.cayenne.dbsync.reverse.dbimport.Catalog)10 IncludeColumn (org.apache.cayenne.dbsync.reverse.dbimport.IncludeColumn)10 Schema (org.apache.cayenne.dbsync.reverse.dbimport.Schema)10 DbImportTreeNode (org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode)9 ExcludeTable (org.apache.cayenne.dbsync.reverse.dbimport.ExcludeTable)6 ReverseEngineering (org.apache.cayenne.dbsync.reverse.dbimport.ReverseEngineering)6 ExcludeColumn (org.apache.cayenne.dbsync.reverse.dbimport.ExcludeColumn)5 FilterContainer (org.apache.cayenne.dbsync.reverse.dbimport.FilterContainer)5 TransferableNode (org.apache.cayenne.modeler.dialog.db.load.TransferableNode)4 Test (org.junit.Test)3 ArrayList (java.util.ArrayList)2 IncludeProcedure (org.apache.cayenne.dbsync.reverse.dbimport.IncludeProcedure)2 DbImportView (org.apache.cayenne.modeler.editor.dbimport.DbImportView)2 DBConnectionInfo (org.apache.cayenne.modeler.pref.DBConnectionInfo)2 SQLException (java.sql.SQLException)1 TreePath (javax.swing.tree.TreePath)1 DbImportConfiguration (org.apache.cayenne.dbsync.reverse.dbimport.DbImportConfiguration)1 ExcludeProcedure (org.apache.cayenne.dbsync.reverse.dbimport.ExcludeProcedure)1 ExcludeRelationship (org.apache.cayenne.dbsync.reverse.dbimport.ExcludeRelationship)1