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;
}
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());
}
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());
}
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);
}
}
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());
}
Aggregations