use of org.apache.cayenne.dbsync.reverse.dbimport.Catalog in project cayenne by apache.
the class DbImporterOldMojoConfigurationTest method testLoadCatalog.
public void testLoadCatalog() throws Exception {
Map<String, Catalog> catalogs = new HashMap<>();
for (Catalog c : getCdbImport("pom-catalog.xml").getReverseEngineering().getCatalogs()) {
catalogs.put(c.getName(), c);
}
assertEquals(3, catalogs.size());
Catalog c3 = catalogs.get("catalog-name-03");
assertNotNull(c3);
assertCatalog(c3);
}
use of org.apache.cayenne.dbsync.reverse.dbimport.Catalog in project cayenne by apache.
the class FiltersConfigBuilderTest method testCompact_full.
@Test
public void testCompact_full() {
ReverseEngineering engineering = new ReverseEngineering();
Catalog cat01 = new Catalog("cat_01");
Schema sch01 = new Schema("sch_01");
sch01.addIncludeTable(includeTable("t1", "c11", "c12"));
sch01.addExcludeTable(new ExcludeTable("t2"));
sch01.addIncludeProcedure(new IncludeProcedure("p1"));
sch01.addExcludeProcedure(new ExcludeProcedure("p2"));
sch01.addIncludeColumn(new IncludeColumn("c_x1"));
sch01.addExcludeColumn(new ExcludeColumn("c_x2"));
cat01.addSchema(sch01);
cat01.addIncludeTable(includeTable("t3", "c31", "c32"));
cat01.addExcludeTable(new ExcludeTable("t4"));
cat01.addIncludeProcedure(new IncludeProcedure("p3"));
cat01.addExcludeProcedure(new ExcludeProcedure("p4"));
cat01.addIncludeColumn(new IncludeColumn("c_xx1"));
cat01.addExcludeColumn(new ExcludeColumn("c_xx2"));
engineering.addCatalog(cat01);
Schema sch02 = new Schema("sch_02");
sch02.addIncludeTable(includeTable("t5", "c51", "c52"));
sch02.addExcludeTable(new ExcludeTable("t6"));
sch02.addIncludeProcedure(new IncludeProcedure("p5"));
sch02.addExcludeProcedure(new ExcludeProcedure("p6"));
sch02.addIncludeColumn(new IncludeColumn("c2_x1"));
sch02.addExcludeColumn(new ExcludeColumn("c2_x2"));
engineering.addSchema(sch02);
engineering.addIncludeTable(includeTable("t7", "c71", "c72"));
engineering.addExcludeTable(new ExcludeTable("t8"));
engineering.addIncludeProcedure(new IncludeProcedure("p7"));
engineering.addExcludeProcedure(new ExcludeProcedure("p8"));
engineering.addIncludeColumn(new IncludeColumn("c_xxx1"));
engineering.addExcludeColumn(new ExcludeColumn("c_xxx2"));
FiltersConfigBuilder builder = new FiltersConfigBuilder(engineering);
assertEquals("Original ReverseEngineering should be", "ReverseEngineering: \n" + " Catalog: cat_01\n" + " Schema: sch_01\n" + " IncludeTable: t1\n" + " IncludeColumn: c11\n" + " ExcludeColumn: c12\n" + " ExcludeTable: t2\n" + " IncludeColumn: c_x1\n" + " ExcludeColumn: c_x2\n" + " IncludeProcedure: p1\n" + " ExcludeProcedure: p2\n" + " IncludeTable: t3\n" + " IncludeColumn: c31\n" + " ExcludeColumn: c32\n" + " ExcludeTable: t4\n" + " IncludeColumn: c_xx1\n" + " ExcludeColumn: c_xx2\n" + " IncludeProcedure: p3\n" + " ExcludeProcedure: p4\n" + " Schema: sch_02\n" + " IncludeTable: t5\n" + " IncludeColumn: c51\n" + " ExcludeColumn: c52\n" + " ExcludeTable: t6\n" + " IncludeColumn: c2_x1\n" + " ExcludeColumn: c2_x2\n" + " IncludeProcedure: p5\n" + " ExcludeProcedure: p6\n" + " IncludeTable: t7\n" + " IncludeColumn: c71\n" + " ExcludeColumn: c72\n" + " ExcludeTable: t8\n" + " IncludeColumn: c_xxx1\n" + " ExcludeColumn: c_xxx2\n" + " IncludeProcedure: p7\n" + " ExcludeProcedure: p8\n\n" + " Use primitives", engineering.toString());
builder.compact();
assertEquals("ReverseEngineering: \n" + " Catalog: cat_01\n" + " Schema: sch_01\n" + " IncludeTable: t1\n" + " IncludeColumn: c11\n" + " IncludeColumn: c_xxx1\n" + " IncludeColumn: c_xx1\n" + " IncludeColumn: c_x1\n" + " ExcludeColumn: c12\n" + " ExcludeColumn: c_xxx2\n" + " ExcludeColumn: c_xx2\n" + " ExcludeColumn: c_x2\n" + " IncludeTable: t7\n" + " IncludeColumn: c71\n" + " IncludeColumn: c_xxx1\n" + " ExcludeColumn: c72\n" + " ExcludeColumn: c_xxx2\n" + " IncludeTable: t3\n" + " IncludeColumn: c31\n" + " IncludeColumn: c_xxx1\n" + " IncludeColumn: c_xx1\n" + " ExcludeColumn: c32\n" + " ExcludeColumn: c_xxx2\n" + " ExcludeColumn: c_xx2\n" + " ExcludeTable: t2\n" + " ExcludeTable: t8\n" + " ExcludeTable: t4\n" + " IncludeProcedure: p1\n" + " IncludeProcedure: p7\n" + " IncludeProcedure: p3\n" + " ExcludeProcedure: p2\n" + " ExcludeProcedure: p8\n" + " ExcludeProcedure: p4\n" + " Schema: sch_02\n" + " IncludeTable: t5\n" + " IncludeColumn: c51\n" + " IncludeColumn: c_xxx1\n" + " IncludeColumn: c2_x1\n" + " ExcludeColumn: c52\n" + " ExcludeColumn: c_xxx2\n" + " ExcludeColumn: c2_x2\n" + " IncludeTable: t7\n" + " IncludeColumn: c71\n" + " IncludeColumn: c_xxx1\n" + " ExcludeColumn: c72\n" + " ExcludeColumn: c_xxx2\n" + " ExcludeTable: t6\n" + " ExcludeTable: t8\n" + " IncludeProcedure: p5\n" + " IncludeProcedure: p7\n" + " ExcludeProcedure: p6\n" + " ExcludeProcedure: p8\n\n" + " Use primitives", engineering.toString());
}
use of org.apache.cayenne.dbsync.reverse.dbimport.Catalog in project cayenne by apache.
the class DatabaseSchemaLoader method packProcedures.
private void packProcedures(Connection connection) throws SQLException {
Collection<Catalog> catalogs = databaseReverseEngineering.getCatalogs();
for (Catalog catalog : catalogs) {
Collection<Schema> schemas = catalog.getSchemas();
if (!schemas.isEmpty()) {
for (Schema schema : schemas) {
ResultSet procResultSet = getProcedures(connection, catalog.getName(), schema.getName());
packProcedures(procResultSet, schema);
}
} else {
ResultSet procResultSet = getProcedures(connection, catalog.getName(), null);
packProcedures(procResultSet, catalog);
}
}
Collection<Schema> schemas = databaseReverseEngineering.getSchemas();
for (Schema schema : schemas) {
ResultSet procResultSet = getProcedures(connection, null, schema.getName());
packProcedures(procResultSet, schema);
}
}
use of org.apache.cayenne.dbsync.reverse.dbimport.Catalog in project cayenne by apache.
the class DbImportTree method findNodeInParent.
DbImportTreeNode findNodeInParent(DbImportTreeNode parent, Object object) {
for (int i = 0; i < parent.getChildCount(); i++) {
DbImportTreeNode node = (DbImportTreeNode) parent.getChildAt(i);
Object userObject = node.getUserObject();
if (object instanceof Catalog) {
Catalog catalog = (Catalog) object;
if (!(userObject instanceof Catalog)) {
continue;
}
Catalog currentCatalog = (Catalog) userObject;
if (currentCatalog.getName().equals(catalog.getName())) {
return node;
}
}
if (object instanceof Schema) {
Schema schema = (Schema) object;
if (!(userObject instanceof Schema)) {
continue;
}
Schema currentSchema = (Schema) userObject;
if (currentSchema.getName().equals(schema.getName())) {
return node;
}
}
if (object instanceof IncludeTable) {
IncludeTable table = (IncludeTable) object;
if (!(userObject instanceof IncludeTable)) {
continue;
}
IncludeTable currentTable = (IncludeTable) userObject;
if (currentTable.getPattern().equals(table.getPattern())) {
return node;
}
}
if (object instanceof ExcludeTable) {
ExcludeTable table = (ExcludeTable) object;
if (!(userObject instanceof ExcludeTable)) {
continue;
}
ExcludeTable currentTable = (ExcludeTable) userObject;
if (currentTable.getPattern().equals(table.getPattern())) {
return node;
}
}
}
return null;
}
use of org.apache.cayenne.dbsync.reverse.dbimport.Catalog in project cayenne by apache.
the class FiltersConfigBuilder method compactTableFilter.
private void compactTableFilter() {
Collection<IncludeTable> engIncludeTables = engineering.getIncludeTables();
Collection<ExcludeTable> engExcludeTables = engineering.getExcludeTables();
for (Catalog catalog : engineering.getCatalogs()) {
Collection<IncludeTable> catalogIncludeTables = catalog.getIncludeTables();
Collection<ExcludeTable> catalogExcludeTables = catalog.getExcludeTables();
for (Schema schema : catalog.getSchemas()) {
schema.getIncludeTables().addAll(engIncludeTables);
schema.getIncludeTables().addAll(catalogIncludeTables);
schema.getExcludeTables().addAll(engExcludeTables);
schema.getExcludeTables().addAll(catalogExcludeTables);
}
}
for (Schema schema : engineering.getSchemas()) {
schema.getIncludeTables().addAll(engIncludeTables);
schema.getExcludeTables().addAll(engExcludeTables);
}
}
Aggregations