@Test public void testDatabaseWithDomains() throws Exception { String expected = "\n" + "\n" + "CREATE DATABASE foo VERSION '2';\n" + "USE DATABASE foo VERSION '2';\n" + "\n" + "--############ Domains ############\n" + "CREATE DOMAIN x AS string(1000) NOT NULL;\n\n" + "CREATE DOMAIN y AS integer NOT NULL;\n\n" + "CREATE DOMAIN z AS bigdecimal(10,2) NOT NULL;\n\n" + "\n--############ Schemas ############\n" + "CREATE VIRTUAL SCHEMA SchemaA;\n\n" + "\n--############ Schema:SchemaA ############\n" + "SET SCHEMA SchemaA;\n" + "\n" + "CREATE VIEW G1 (\n" + "\te1 x,\n" + "\te2 y\n" + ")\nAS\nSELECT 'a', 1;\n" + "\n" + "\n"; Database db = TestDDLParser.helpParse(expected); String metadataDDL = DDLStringVisitor.getDDLString(db); assertEquals(expected, metadataDDL); }
public static String getDDLString(Schema schema, EnumSet<SchemaObjectType> types, String regexPattern) { DDLStringVisitor visitor = new DDLStringVisitor(types, regexPattern); visitor.visit(schema); return visitor.toString(); }
DDLStringVisitor { public static String getDDLString(Schema schema, EnumSet<SchemaObjectType> types, String regexPattern) { DDLStringVisitor visitor = new DDLStringVisitor(types, regexPattern); visitor.visit(schema); return visitor.toString(); } }
DDLStringVisitor { public static String getDDLString(Schema schema, EnumSet<SchemaObjectType> types, String regexPattern) { DDLStringVisitor visitor = new DDLStringVisitor(types, regexPattern); visitor.visit(schema); return visitor.toString(); } DDLStringVisitor(EnumSet<SchemaObjectType> types, String regexPattern); }
DDLStringVisitor { public static String getDDLString(Schema schema, EnumSet<SchemaObjectType> types, String regexPattern) { DDLStringVisitor visitor = new DDLStringVisitor(types, regexPattern); visitor.visit(schema); return visitor.toString(); } DDLStringVisitor(EnumSet<SchemaObjectType> types, String regexPattern); static String getDDLString(Schema schema, EnumSet<SchemaObjectType> types, String regexPattern); static String getDDLString(Database database); void visit(Database database); String addTableBody(Table table); @Override String toString(); static String getDomainDDLString(Database database); }
DDLStringVisitor { public static String getDDLString(Schema schema, EnumSet<SchemaObjectType> types, String regexPattern) { DDLStringVisitor visitor = new DDLStringVisitor(types, regexPattern); visitor.visit(schema); return visitor.toString(); } DDLStringVisitor(EnumSet<SchemaObjectType> types, String regexPattern); static String getDDLString(Schema schema, EnumSet<SchemaObjectType> types, String regexPattern); static String getDDLString(Database database); void visit(Database database); String addTableBody(Table table); @Override String toString(); static String getDomainDDLString(Database database); static final String GENERATED; }