CreateSchemaForRDBMSApp extends MdmsAppTemplate<CreateSchemaForRDBMSApp.Parameters> { public static void fromParameters(MetadataStore mds, String jdbcUrl, String schemaName, String dbSchemaName, String pgpassPath, String driverClassName, String detectionMethod) throws Exception { CreateSchemaForRDBMSApp.Parameters parameters = new CreateSchemaForRDBMSApp.Parameters(); parameters.jdbcUrl = jdbcUrl; parameters.schemaName = schemaName; parameters.dbSchema = dbSchemaName; parameters.pgPassPath = pgpassPath; parameters.driverClassName = driverClassName; parameters.detection = detectionMethod; parameters.metadataStoreParameters.isCloseMetadataStore = false; CreateSchemaForRDBMSApp app = new CreateSchemaForRDBMSApp(parameters); app.metadataStore = mds; app.run(); } CreateSchemaForRDBMSApp(final CreateSchemaForRDBMSApp.Parameters parameters); static void fromParameters(MetadataStore mds,
                                      String jdbcUrl,
                                      String schemaName,
                                      String dbSchemaName,
                                      String pgpassPath,
                                      String driverClassName,
                                      String detectionMethod); static void main(final String[] args);  }
@Test public void testImportViaFromParameters() throws Exception { MetadataStore metadataStore = new DefaultMetadataStore(); File testFolder = getTestResource("test-database.db"); CreateSchemaForRDBMSApp.fromParameters( metadataStore, "jdbc:sqlite:/" + testFolder.getAbsolutePath(), "test-schema", null, null, org.sqlite.JDBC.class.getCanonicalName(), "JDBC" ); Schema schema = metadataStore.getSchemaByName("test-schema"); Assert.assertNotNull("test-schema"); Assert.assertEquals(9, schema.getTables().size()); Table target = metadataStore.getTableByName("test-schema.Target"); Assert.assertEquals(6, target.getColumns().size()); Column targetData = metadataStore.getColumnByName("test-schema.Target.data"); Assert.assertNotNull(targetData); }
@Test public void testImportToSqliteViaFromParameters() throws Exception { File dbFile = File.createTempFile("test", "db"); dbFile.deleteOnExit(); SQLiteInterface sqliteInterface = SQLiteInterface.createForFile(dbFile); MetadataStore metadataStore = RDBMSMetadataStore.createNewInstance(sqliteInterface); File testFolder = getTestResource("test-database.db"); CreateSchemaForRDBMSApp.fromParameters( metadataStore, "jdbc:sqlite:/" + testFolder.getAbsolutePath(), "test-schema", null, null, org.sqlite.JDBC.class.getCanonicalName(), "JDBC" ); Schema schema = metadataStore.getSchemaByName("test-schema"); Assert.assertNotNull("test-schema"); Assert.assertEquals(9, schema.getTables().size()); Table target = metadataStore.getTableByName("test-schema.Target"); Assert.assertEquals(6, target.getColumns().size()); Column targetData = metadataStore.getColumnByName("test-schema.Target.data"); Assert.assertNotNull(targetData); }