Search in sources :

Example 16 with Catalog

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

the class FiltersConfigBuilder method transformCatalogs.

private CatalogFilter[] transformCatalogs(Collection<Catalog> catalogs) {
    CatalogFilter[] catalogFilters = new CatalogFilter[catalogs.size()];
    int i = 0;
    for (Catalog catalog : catalogs) {
        catalogFilters[i] = new CatalogFilter(catalog.getName(), transformSchemas(catalog.getSchemas()));
        i++;
    }
    return catalogFilters;
}
Also used : Catalog(org.apache.cayenne.dbsync.reverse.dbimport.Catalog)

Example 17 with Catalog

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

the class DbImporterMojoTest method testSupportsCatalogsOnReverseEngineering.

@Test
public void testSupportsCatalogsOnReverseEngineering() throws Exception {
    DbImporterMojo cdbImport = getCdbImport("dbimport/testSupportsCatalogsOnReverseEngineering-pom.xml");
    cdbImport.getReverseEngineering().addCatalog(new Catalog("DbImporterMojoTest2"));
    Exception exceptedException = null;
    String exceptedMessage = "Your database does not support catalogs on reverse engineering. " + "It allows to connect to only one at the moment. Please don't note catalogs in <dbimport> configuration.";
    try {
        cdbImport.execute();
    } catch (MojoExecutionException ex) {
        exceptedException = ex;
    }
    assertNotNull(exceptedException);
    assertEquals(exceptedMessage, exceptedException.getCause().getMessage());
}
Also used : MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) Catalog(org.apache.cayenne.dbsync.reverse.dbimport.Catalog) SQLException(java.sql.SQLException) IOException(java.io.IOException) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) Test(org.junit.Test)

Example 18 with Catalog

use of org.apache.cayenne.dbsync.reverse.dbimport.Catalog 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 19 with Catalog

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

the class DeleteNodeAction method performAction.

@Override
public void performAction(ActionEvent e) {
    tree.stopEditing();
    final TreePath[] paths = tree.getSelectionPaths();
    final DbImportView rootParent = ((DbImportView) panel.getParent().getParent());
    rootParent.getLoadDbSchemaButton().setEnabled(false);
    rootParent.getReverseEngineeringProgress().setVisible(true);
    if (paths != null) {
        ReverseEngineering reverseEngineeringOldCopy = new ReverseEngineering(tree.getReverseEngineering());
        rootParent.lockToolbarButtons();
        for (TreePath path : paths) {
            selectedElement = (DbImportTreeNode) path.getLastPathComponent();
            parentElement = (DbImportTreeNode) selectedElement.getParent();
            if (parentElement != null) {
                Object parentUserObject = parentElement.getUserObject();
                if (parentUserObject instanceof ReverseEngineering) {
                    ReverseEngineering reverseEngineering = (ReverseEngineering) parentUserObject;
                    deleteChilds(reverseEngineering);
                } else if (parentUserObject instanceof Catalog) {
                    Catalog catalog = (Catalog) parentUserObject;
                    deleteChilds(catalog);
                } else if (parentUserObject instanceof Schema) {
                    Schema schema = (Schema) parentUserObject;
                    deleteChilds(schema);
                } else if (parentUserObject instanceof IncludeTable) {
                    IncludeTable includeTable = (IncludeTable) parentUserObject;
                    deleteChilds(includeTable);
                }
            }
        }
        if (paths.length > 1) {
            getProjectController().setDirty(true);
            ArrayList<DbImportTreeNode> expandList = tree.getTreeExpandList();
            tree.translateReverseEngineeringToTree(tree.getReverseEngineering(), false);
            tree.expandTree(expandList);
        } else {
            updateParentChilds();
        }
        putReverseEngineeringToUndoManager(reverseEngineeringOldCopy);
        rootParent.getLoadDbSchemaButton().setEnabled(true);
        rootParent.getReverseEngineeringProgress().setVisible(false);
    }
}
Also used : DbImportView(org.apache.cayenne.modeler.editor.dbimport.DbImportView) TreePath(javax.swing.tree.TreePath) ReverseEngineering(org.apache.cayenne.dbsync.reverse.dbimport.ReverseEngineering) 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) Catalog(org.apache.cayenne.dbsync.reverse.dbimport.Catalog)

Example 20 with Catalog

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

the class FiltersConfigBuilderTest method testCompact_03.

@Test
public void testCompact_03() {
    ReverseEngineering engineering = new ReverseEngineering();
    engineering.addCatalog(new Catalog("APP1"));
    engineering.addCatalog(new Catalog("APP2"));
    engineering.addExcludeTable(new ExcludeTable("SYS_.*"));
    engineering.addExcludeColumn(new ExcludeColumn("calculated_.*"));
    FiltersConfigBuilder builder = new FiltersConfigBuilder(engineering);
    builder.compact();
    assertEquals("ReverseEngineering: \n" + "  Catalog: APP1\n" + "    Schema: null\n" + "      IncludeTable: null\n" + "        ExcludeColumn: calculated_.*\n" + "      ExcludeTable: SYS_.*\n" + "  Catalog: APP2\n" + "    Schema: null\n" + "      IncludeTable: null\n" + "        ExcludeColumn: calculated_.*\n" + "      ExcludeTable: SYS_.*\n\n" + "  Use primitives", engineering.toString());
}
Also used : ReverseEngineering(org.apache.cayenne.dbsync.reverse.dbimport.ReverseEngineering) ExcludeColumn(org.apache.cayenne.dbsync.reverse.dbimport.ExcludeColumn) Catalog(org.apache.cayenne.dbsync.reverse.dbimport.Catalog) ExcludeTable(org.apache.cayenne.dbsync.reverse.dbimport.ExcludeTable) Test(org.junit.Test)

Aggregations

Catalog (org.apache.cayenne.dbsync.reverse.dbimport.Catalog)30 Schema (org.apache.cayenne.dbsync.reverse.dbimport.Schema)18 IncludeTable (org.apache.cayenne.dbsync.reverse.dbimport.IncludeTable)11 ExcludeTable (org.apache.cayenne.dbsync.reverse.dbimport.ExcludeTable)7 ReverseEngineering (org.apache.cayenne.dbsync.reverse.dbimport.ReverseEngineering)7 Test (org.junit.Test)7 DbImportTreeNode (org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode)6 ResultSet (java.sql.ResultSet)4 IncludeColumn (org.apache.cayenne.dbsync.reverse.dbimport.IncludeColumn)4 ArrayList (java.util.ArrayList)3 ExcludeColumn (org.apache.cayenne.dbsync.reverse.dbimport.ExcludeColumn)3 FilterContainer (org.apache.cayenne.dbsync.reverse.dbimport.FilterContainer)3 IncludeProcedure (org.apache.cayenne.dbsync.reverse.dbimport.IncludeProcedure)3 Connection (java.sql.Connection)2 SQLException (java.sql.SQLException)2 HashMap (java.util.HashMap)2 TreePath (javax.swing.tree.TreePath)2 ExcludeProcedure (org.apache.cayenne.dbsync.reverse.dbimport.ExcludeProcedure)2 TransferableNode (org.apache.cayenne.modeler.dialog.db.load.TransferableNode)2 DbImportView (org.apache.cayenne.modeler.editor.dbimport.DbImportView)2