/** * Create an instance of {@link MappedSchema } * */ public MappedSchema createMappedSchema() { return new MappedSchema(); }
private final boolean matches(MappedSchema s, String schemaName) { return (s.getInput() != null && schemaName.equals(s.getInput())) || (s.getInputExpression() != null && s.getInputExpression().matcher(schemaName).matches()); }
public MappedSchema withTables(Collection<MappedTable> values) { if (values!= null) { getTables().addAll(values); } return this; }
if (inputTable.getSchema().getName().equals(s.getInput())) { for (MappedTable t : s.getTables()) { if (inputTable.getName().equals(t.getInput())) { table = t; schema = new MappedSchema().withInput(inputTable.getSchema().getName()); mapping().getSchemata().add(schema); schema.getTables().add(table);
/** * Add schemata to this mapping * * @param inputSchema The schema known at codegen time to be mapped * @param outputSchema The schema configured at run time to be mapped */ public void add(String inputSchema, String outputSchema) { logDeprecation(); // Find existing mapped schema MappedSchema schema = null; for (MappedSchema s : mapping().getSchemata()) { if (inputSchema.equals(s.getInput())) { schema = s; break; } } if (schema == null) { schema = new MappedSchema().withInput(inputSchema); mapping().getSchemata().add(schema); } // Add new mapping schema.setOutput(outputSchema); }
public PluginDao(final DataSource dataSource, final SQLDialect dialect) throws SQLException { this.dataSource = dataSource; this.dialect = dialect; switch (dialect) { case H2: final String schema; Connection connection = null; try { connection = dataSource.getConnection(); schema = connection.getSchema(); } finally { if (connection != null) { connection.close(); } } final MappedSchema mappedSchema = new MappedSchema().withInput(DEFAULT_SCHEMA_NAME) // As defined by the jOOQ codegen .withOutput(schema); final RenderMapping renderMapping = new RenderMapping().withSchemata(mappedSchema); this.settings = new Settings().withRenderMapping(renderMapping) .withRenderNameStyle(RenderNameStyle.UPPER); break; default: // For MySQL, schema doesn't matter. // For PostgreSQL, assume schema is part of the JDBC url this.settings = new Settings().withRenderSchema(false); break; } }
if (!isBlank(s.getOutput())) if (s.getInput() != null && !s.getOutput().equals(schemaName)) result = new RenamedSchema(result, s.getOutput()); else if (s.getInputExpression() != null) result = new RenamedSchema(result, s.getInputExpression().matcher(schemaName).replaceAll(s.getOutput()));
public MappedSchema withOutput(String value) { setOutput(value); return this; }
public MappedSchema withTables(List<MappedTable> tables) { setTables(tables); return this; }
public MappedSchema withInput(String value) { setInput(value); return this; }
if (inputTable.getSchema().getName().equals(s.getInput())) { for (MappedTable t : s.getTables()) { if (inputTable.getName().equals(t.getInput())) { table = t; schema = new MappedSchema().withInput(inputTable.getSchema().getName()); mapping().getSchemata().add(schema); schema.getTables().add(table);
/** * Add schemata to this mapping * * @param inputSchema The schema known at codegen time to be mapped * @param outputSchema The schema configured at run time to be mapped */ public void add(String inputSchema, String outputSchema) { logDeprecation(); // Find existing mapped schema MappedSchema schema = null; for (MappedSchema s : mapping().getSchemata()) { if (inputSchema.equals(s.getInput())) { schema = s; break; } } if (schema == null) { schema = new MappedSchema().withInput(inputSchema); mapping().getSchemata().add(schema); } // Add new mapping schema.setOutput(outputSchema); }
@Test(groups = "fast") public void testBuildSettings() throws Exception { final String settingsXML = "<settings xmlns=\"http://www.jooq.org/xsd/jooq-runtime-3.10.2.xsd\">\n" + " <renderMapping>\n" + " <schemata>\n" + " <schema>\n" + " <input>DEV</input>\n" + " <tables>\n" + " <table>\n" + " <input>AUTHOR</input>\n" + " <output>MY_APP__AUTHOR</output>\n" + " </table>\n" + " </tables>\n" + " </schema>\n" + " </schemata>\n" + " </renderMapping>\n" + "</settings>"; final Settings settings = PluginDao.getSettings(new ByteArrayInputStream(settingsXML.getBytes())); Assert.assertNotNull(settings); Assert.assertNotNull(settings.getRenderMapping()); Assert.assertNotNull(settings.getRenderMapping().getSchemata()); Assert.assertEquals(settings.getRenderMapping().getSchemata().size(), 1); Assert.assertEquals(settings.getRenderMapping().getSchemata().get(0).getInput(), "DEV"); Assert.assertEquals(settings.getRenderMapping().getSchemata().get(0).getTables().size(), 1); Assert.assertEquals(settings.getRenderMapping().getSchemata().get(0).getTables().get(0).getInput(), "AUTHOR"); Assert.assertEquals(settings.getRenderMapping().getSchemata().get(0).getTables().get(0).getOutput(), "MY_APP__AUTHOR"); } }
public MappedSchema withOutput(String value) { setOutput(value); return this; }
public MappedSchema withTables(List<MappedTable> tables) { setTables(tables); return this; }
public MappedSchema withInput(String value) { setInput(value); return this; }
/** * Create an instance of {@link MappedSchema } * */ public MappedSchema createMappedSchema() { return new MappedSchema(); }
public MappedSchema withTables(MappedTable... values) { if (values!= null) { for (MappedTable value: values) { getTables().add(value); } } return this; }